Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #764 from mojombo/jekyll-new
`jekyll new`: scaffold site generator
- Loading branch information
Showing
13 changed files
with
502 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'erb' | ||
|
||
module Jekyll | ||
module Commands | ||
class New < Command | ||
def self.process(args) | ||
raise ArgumentError.new('You must specify a path.') if args.empty? | ||
|
||
new_blog_path = File.expand_path(args.join(" "), Dir.pwd) | ||
FileUtils.mkdir_p new_blog_path | ||
|
||
create_sample_files new_blog_path | ||
|
||
File.open(File.expand_path(self.initialized_post_name, new_blog_path), "w") do |f| | ||
f.write(self.scaffold_post_content(site_template)) | ||
end | ||
puts "New jekyll site installed in #{new_blog_path}." | ||
end | ||
|
||
def self.scaffold_post_content(template_site) | ||
ERB.new(File.read(File.expand_path(scaffold_path, site_template))).result | ||
end | ||
|
||
# Internal: Gets the filename of the sample post to be created | ||
# | ||
# Returns the filename of the sample post, as a String | ||
def self.initialized_post_name | ||
"_posts/#{Time.now.strftime('%Y-%m-%d')}-welcome-to-jekyll.markdown" | ||
end | ||
|
||
private | ||
def self.create_sample_files(path) | ||
FileUtils.cp_r site_template + '/.', path | ||
FileUtils.rm File.expand_path(scaffold_path, path) | ||
end | ||
|
||
def self.site_template | ||
File.expand_path("../../site_template", File.dirname(__FILE__)) | ||
end | ||
|
||
def self.scaffold_path | ||
"_posts/0000-00-00-welcome-to-jekyll.markdown.erb" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
markdown: rdiscount | ||
pygments: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<title>{{ page.title }}</title> | ||
<!-- syntax highlighting CSS --> | ||
<link rel="stylesheet" href="/css/syntax.css" type="text/css" /> | ||
<!-- Homepage CSS --> | ||
<link rel="stylesheet" href="/css/screen.css" type="text/css" media="screen, projection" /> | ||
</head> | ||
<body> | ||
<div class="site"> | ||
<div class="title"> | ||
<a href="/">Your Name</a> | ||
<a class="extra" href="/">home</a> | ||
</div> | ||
|
||
{{ content }} | ||
|
||
<div class="footer"> | ||
<div class="contact"> | ||
<p> | ||
Your Name<br /> | ||
What You Are<br /> | ||
your@email.com | ||
</p> | ||
</div> | ||
<div class="contact"> | ||
<p> | ||
<a href="http://github.com/yourusername/">github.com/yourusername</a><br /> | ||
<a href="http://twitter.com/yourusername/">twitter.com/yourusername</a><br /> | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<a href="http://github.com/yourusername"><img style="position: absolute; top: 0; right: 0; border: 0;" src="http://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub" /></a> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
layout: default | ||
--- | ||
<div id="post"> | ||
{{ content }} | ||
</div> |
24 changes: 24 additions & 0 deletions
24
lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
layout: post | ||
title: "Welcome to Jekyll!" | ||
date: <%= Time.now.strftime('%Y-%m-%d %H:%M:%S') %> | ||
categories: jekyll update | ||
--- | ||
|
||
You'll find this post in your `_posts` directory - edit this post and re-build (or run with the `-w` switch) to see your changes! | ||
To add new posts, simply add a file in the `_posts` directory that follows the convention: YYYY-MM-DD-name-of-post.ext. | ||
|
||
Jekyll also offers powerful support for code snippets: | ||
|
||
{% highlight ruby %} | ||
def print_hi(name) | ||
puts "Hi, #{name}" | ||
end | ||
print_hi('Tom') | ||
#=> prints 'Hi, Tom' to STDOUT. | ||
{% endhighlight %} | ||
|
||
Check out the [Jekyll docs][jekyll] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll's GitHub repo][jekyll-gh]. | ||
|
||
[jekyll-gh]: https://github.com/mojombo/jekyll | ||
[jekyll]: http://jekyllrb.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
/*****************************************************************************/ | ||
/* | ||
/* Common | ||
/* | ||
/*****************************************************************************/ | ||
|
||
/* Global Reset */ | ||
|
||
* { | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
html, body { | ||
height: 100%; | ||
} | ||
|
||
body { | ||
background-color: white; | ||
font: 13.34px helvetica, arial, clean, sans-serif; | ||
*font-size: small; | ||
text-align: center; | ||
} | ||
|
||
h1, h2, h3, h4, h5, h6 { | ||
font-size: 100%; | ||
} | ||
|
||
h1 { | ||
margin-bottom: 1em; | ||
} | ||
|
||
p { | ||
margin: 1em 0; | ||
} | ||
|
||
a { | ||
color: #00a; | ||
} | ||
|
||
a:hover { | ||
color: black; | ||
} | ||
|
||
a:visited { | ||
color: #a0a; | ||
} | ||
|
||
table { | ||
font-size: inherit; | ||
font: 100%; | ||
} | ||
|
||
/*****************************************************************************/ | ||
/* | ||
/* Home | ||
/* | ||
/*****************************************************************************/ | ||
|
||
ul.posts { | ||
list-style-type: none; | ||
margin-bottom: 2em; | ||
} | ||
|
||
ul.posts li { | ||
line-height: 1.75em; | ||
} | ||
|
||
ul.posts span { | ||
color: #aaa; | ||
font-family: Monaco, "Courier New", monospace; | ||
font-size: 80%; | ||
} | ||
|
||
/*****************************************************************************/ | ||
/* | ||
/* Site | ||
/* | ||
/*****************************************************************************/ | ||
|
||
.site { | ||
font-size: 110%; | ||
text-align: justify; | ||
width: 42em; | ||
margin: 3em auto 2em auto; | ||
line-height: 1.5em; | ||
} | ||
|
||
.title { | ||
color: #a00; | ||
font-weight: bold; | ||
margin-bottom: 2em; | ||
} | ||
|
||
.site .title a { | ||
color: #a00; | ||
text-decoration: none; | ||
} | ||
|
||
.site .title a:hover { | ||
color: black; | ||
} | ||
|
||
.site .title a.extra { | ||
color: #aaa; | ||
text-decoration: none; | ||
margin-left: 1em; | ||
} | ||
|
||
.site .title a.extra:hover { | ||
color: black; | ||
} | ||
|
||
.site .meta { | ||
color: #aaa; | ||
} | ||
|
||
.site .footer { | ||
font-size: 80%; | ||
color: #666; | ||
border-top: 4px solid #eee; | ||
margin-top: 2em; | ||
overflow: hidden; | ||
} | ||
|
||
.site .footer .contact { | ||
float: left; | ||
margin-right: 3em; | ||
} | ||
|
||
.site .footer .contact a { | ||
color: #8085C1; | ||
} | ||
|
||
.site .footer .rss { | ||
margin-top: 1.1em; | ||
margin-right: -.2em; | ||
float: right; | ||
} | ||
|
||
.site .footer .rss img { | ||
border: 0; | ||
} | ||
|
||
/*****************************************************************************/ | ||
/* | ||
/* Posts | ||
/* | ||
/*****************************************************************************/ | ||
|
||
#post { | ||
|
||
} | ||
|
||
/* standard */ | ||
|
||
#post pre { | ||
border: 1px solid #ddd; | ||
background-color: #eef; | ||
padding: 0 .4em; | ||
} | ||
|
||
#post ul, | ||
#post ol { | ||
margin-left: 1.35em; | ||
} | ||
|
||
#post code { | ||
border: 1px solid #ddd; | ||
background-color: #eef; | ||
font-size: 85%; | ||
padding: 0 .2em; | ||
} | ||
|
||
#post pre code { | ||
border: none; | ||
} | ||
|
||
/* terminal */ | ||
|
||
#post pre.terminal { | ||
border: 1px solid black; | ||
background-color: #333; | ||
color: white; | ||
} | ||
|
||
#post pre.terminal code { | ||
background-color: #333; | ||
} |
Oops, something went wrong.