Merge pull request #5141 from jekyll/remove-example-from-theme
ThemeBuilder: Remove example site from theme
This commit is contained in:
commit
f4c3c5afd6
|
@ -16,7 +16,6 @@ class Jekyll::ThemeBuilder
|
||||||
create_starter_files
|
create_starter_files
|
||||||
create_gemspec
|
create_gemspec
|
||||||
create_accessories
|
create_accessories
|
||||||
create_example_site
|
|
||||||
initialize_git_repo
|
initialize_git_repo
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ class Jekyll::ThemeBuilder
|
||||||
|
|
||||||
def create_directories
|
def create_directories
|
||||||
mkdir_p(SCAFFOLD_DIRECTORIES)
|
mkdir_p(SCAFFOLD_DIRECTORIES)
|
||||||
mkdir_p(%w(example example/_posts))
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_starter_files
|
def create_starter_files
|
||||||
|
@ -72,23 +70,13 @@ class Jekyll::ThemeBuilder
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_accessories
|
def create_accessories
|
||||||
accessories = %w(README.md Rakefile LICENSE.txt)
|
accessories = %w(README.md LICENSE.txt)
|
||||||
accessories << "CODE_OF_CONDUCT.md" if code_of_conduct
|
accessories << "CODE_OF_CONDUCT.md" if code_of_conduct
|
||||||
accessories.each do |filename|
|
accessories.each do |filename|
|
||||||
write_file(filename, template(filename))
|
write_file(filename, template(filename))
|
||||||
end
|
end
|
||||||
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
|
def initialize_git_repo
|
||||||
Jekyll.logger.info "initialize", path.join(".git").to_s
|
Jekyll.logger.info "initialize", path.join(".git").to_s
|
||||||
Dir.chdir(path.to_s) { `git init` }
|
Dir.chdir(path.to_s) { `git init` }
|
||||||
|
|
|
@ -7,8 +7,8 @@ permalink: /about/
|
||||||
This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](http://jekyllrb.com/)
|
This is the base Jekyll theme. You can find out more info about customizing your Jekyll theme, as well as basic Jekyll usage documentation at [jekyllrb.com](http://jekyllrb.com/)
|
||||||
|
|
||||||
You can find the source code for the Jekyll new theme at:
|
You can find the source code for the Jekyll new theme at:
|
||||||
{% include icon-github.html username="jglovier" %} /
|
{% include icon-github.html username="jekyll" %} /
|
||||||
[jekyll-new](https://github.com/jglovier/jekyll-new)
|
[minima](https://github.com/jekyll/minima)
|
||||||
|
|
||||||
You can find the source code for Jekyll at
|
You can find the source code for Jekyll at
|
||||||
{% include icon-github.html username="jekyll" %} /
|
{% include icon-github.html username="jekyll" %} /
|
||||||
|
|
|
@ -38,7 +38,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
|
||||||
|
|
||||||
To set up your environment to develop this theme, run `bundle install`.
|
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.
|
You theme is setup just like a normal Jelyll site! To test your theme, run `bundle exec jekyll serve` and open your browser at `http://localhost:4000`. This starts a Jekyll server using your theme. Add pages, documents, data, etc. like normal to test your theme's contents. As you make modifications to your theme and to your content, your site will regenerate and you should see the changes in the browser after a refresh, just like normal.
|
||||||
|
|
||||||
|
When your theme is released, only the files in `_layouts`, `_includes`, and `_sass` tracked with Git will be released.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
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
|
|
Loading…
Reference in New Issue