Add a Rakefile to do releases as well as adding an example website.

This commit is contained in:
Parker Moore 2016-05-19 14:36:01 -07:00
parent 3885057e9e
commit 20110571ef
No known key found for this signature in database
GPG Key ID: 193CDEBA72063C58
8 changed files with 128 additions and 3 deletions

View File

@ -1,6 +1,6 @@
class Jekyll::ThemeBuilder
SCAFFOLD_DIRECTORIES = %w(
_layouts _includes _sass
_layouts _includes _sass example example/_posts
).freeze
attr_reader :name, :path
@ -14,6 +14,7 @@ class Jekyll::ThemeBuilder
create_directories
create_gemspec
create_accessories
create_example_site
initialize_git_repo
end
@ -62,11 +63,18 @@ class Jekyll::ThemeBuilder
end
def create_accessories
%w(README.md CODE_OF_CONDUCT.md LICENSE.txt).each do |filename|
%w(README.md Rakefile CODE_OF_CONDUCT.md LICENSE.txt).each do |filename|
write_file(filename, template(filename))
end
end
def create_example_site
%w(example/_config.yml example/index.html example/style.scss).each do |filename|
write_file(filename, template(filename))
end
write_file("example/_posts/#{Time.now.strftime("%Y-%m-%d")}-my-example-post.md", template("example/_post.md"))
end
def initialize_git_repo
Jekyll.logger.info "initialize", path.join(".git").to_s
Dir.chdir(path.to_s) { `git init` }

View File

@ -34,6 +34,12 @@ TODO: Write usage instructions here. Describe your available layouts, includes,
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hello. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
## Development
To set up your environment to develop this theme, run `bundle install`.
To test your theme, run `bundle exec rake preview` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme and the contents of the `example/` directory. As you make modifications to your theme and to the example site, your site will regenerate and you should see the changes in the browser after a refresh.
## License
The theme is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).

View File

@ -0,0 +1,74 @@
require "bundler/gem_tasks"
require "jekyll"
require "listen"
def listen_ignore_paths(base, options)
[
/_config\.ya?ml/,
/_site/,
/\.jekyll-metadata/
]
end
def listen_handler(base, options)
site = Jekyll::Site.new(options)
Jekyll::Command.process_site(site)
proc do |modified, added, removed|
t = Time.now
c = modified + added + removed
n = c.length
relative_paths = c.map{ |p| Pathname.new(p).relative_path_from(base).to_s }
print Jekyll.logger.message("Regenerating:", "#{relative_paths.join(", ")} changed... ")
begin
Jekyll::Command.process_site(site)
puts "regenerated in #{Time.now - t} seconds."
rescue => e
puts "error:"
Jekyll.logger.warn "Error:", e.message
Jekyll.logger.warn "Error:", "Run jekyll build --trace for more information."
end
end
end
task :preview do
base = Pathname.new('.').expand_path
options = {
"source" => base.join('example').to_s,
"destination" => base.join('example/_site').to_s,
"force_polling" => false,
"serving" => true,
"theme" => <%= theme_name.inspect %>
}
options = Jekyll.configuration(options)
ENV["LISTEN_GEM_DEBUGGING"] = "1"
listener = Listen.to(
base.join("_includes"),
base.join("_layouts"),
base.join("_sass"),
options["source"],
:ignore => listen_ignore_paths(base, options),
:force_polling => options['force_polling'],
&(listen_handler(base, options))
)
begin
listener.start
Jekyll.logger.info "Auto-regeneration:", "enabled for '#{options["source"]}'"
unless options['serving']
trap("INT") do
listener.stop
puts " Halting auto-regeneration."
exit 0
end
loop { sleep 1000 }
end
rescue ThreadError
# You pressed Ctrl-C, oh my!
end
Jekyll::Commands::Serve.process(options)
end

View File

@ -0,0 +1 @@
theme: <%= theme_name %>

View File

@ -0,0 +1,13 @@
---
# Specify a layout from your theme!
# This will be the layout users specify for their posts.
---
Eos eu docendi tractatos sapientem, brute option menandri in vix, quando vivendo accommodare te ius. Nec melius fastidii constituam id, viderer theophrastus ad sit, hinc semper periculis cum id. Noluisse postulant assentior est in, no choro sadipscing repudiandae vix. Vis in euismod delenit dignissim. Ex quod nostrum sit, suas decore animal id ius, nobis solet detracto quo te.
{% comment %}
Might you have an include in your theme? Why not try it here!
{% include my-themes-great-include.html %}
{% endcomment %}
No laudem altera adolescens has, volumus lucilius eum no. Eam ei nulla audiam efficiantur. Suas affert per no, ei tale nibh sea. Sea ne magna harum, in denique scriptorem sea, cetero alienum tibique ei eos. Labores persequeris referrentur eos ei.

View File

@ -0,0 +1,14 @@
---
# Specify a layout from your theme!
---
Lorem ipsum dolor sit amet, quo id prima corrumpit pertinacia, id ius dolor dolores, an veri pertinax explicari mea. Agam solum et qui, his id ludus graeco adipiscing. Duis theophrastus nam in, at his vidisse atomorum. Tantas gloriatur scripserit ne eos. Est wisi tempor habemus at, ei graeco dissentiet eos. Ne usu aliquip sanctus conceptam, te vis ignota animal, modus latine contentiones ius te.
{% for post in site.posts %}
<h2>{{ post.title }}</h2>
<blockquote>{{ post.excerpt }}</blockquote>
{% endfor %}
Te falli veritus sea, at molestiae scribentur deterruisset vix, et mea zril phaedrum vulputate. No cum dicit consulatu. Ut has nostro noluisse expetendis, te pro quaeque disputando, eu sed summo omnes. Eos at tale aperiam, usu cu propriae quaestio constituto, sed aperiam erroribus temporibus an.
Quo eu liber mediocritatem, vix an delectus eleifend, iuvaret suscipit ei vel. Partem invenire per an, mea postulant dissentias eu, ius tantas audire nominavi eu. Dicunt tritani veritus ex vis, mei in case sententiae. At exerci democritum nam, cu lobortis iracundia mei. Alia eligendi consectetuer eu sed, paulo docendi noluisse sit ex.

View File

@ -0,0 +1,7 @@
---
---
// Here, you can test out the Sass/SCSS that you include in your theme.
// Simply `@import` the necessary file(s) to get the proper styles on the site.
// E.g.:
// @import "a-file-from-my-theme";

View File

@ -11,11 +11,13 @@ Gem::Specification.new do |spec|
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.license = "MIT"
spec.metadata["jekyll"] = { "theme" => true }
spec.metadata["plugin_type"] = "theme"
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(exe|<%= theme_directories.join("|") %>)/}) }
spec.bindir = "exe"
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.add_development_dependency "jekyll", "~> <%= jekyll_pessimistic_version %>"
spec.add_development_dependency "bundler", "~> 1.12"
spec.add_development_dependency "rake", "~> 10.0"
end