Skip to content

Commit

Permalink
Add category to rake new_post
Browse files Browse the repository at this point in the history
  • Loading branch information
mmistakes committed Feb 27, 2014
1 parent 938c653 commit 0cdcde1
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 20 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ _site
*.sublime-workspace
codekit-config.json
node_modules
_asset_bundler_cache
Gemfile.lock
_asset_bundler_cache
8 changes: 0 additions & 8 deletions Gemfile

This file was deleted.

2 changes: 2 additions & 0 deletions Rakefile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@
if File.exist?(filename)
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
end
category = get_stdin("Enter category name to group your post in (leave blank for none): ")
tags = get_stdin("Enter tags to classify your post (comma separated): ")
puts "Creating new post: #{filename}"
open(filename, 'w') do |post|
post.puts "---"
post.puts "layout: post"
post.puts "title: \"#{title.gsub(/&/,'&')}\""
post.puts "modified: #{Time.now.strftime('%Y-%m-%d %H:%M:%S %z')}"
post.puts "category: [#{category}]"
post.puts "tags: [#{tags}]"
post.puts "image:"
post.puts " feature: "
Expand Down
12 changes: 2 additions & 10 deletions _layouts/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,15 @@ <h1>{{ page.title }}</h1>
</div><!-- /#main -->

<div class="footer-wrap">
{% if site.related_posts.size > 0 %}<div class="related-articles">
<div class="related-articles">
<h4>You might also enjoy <small class="pull-right">(<a href="{{ site.url }}/posts/">View all posts</a>)</small></h4>
<ul>
{% for post in site.related_posts limit:3 %}
{% assign match = false %}
{% for category in post.categories %}
{% if page.categories contains category %}
{% assign match = true %}
{% endif %}
{% endfor %}
{% if match %}
<li><a href="{{ site.url }}{{ post.url }}" title="{{ post.title }}">{{ post.title }}</a></li>
{% endif %}
{% endfor %}
</ul>
<hr />
</div><!-- /.related-articles -->{% endif %}
</div><!-- /.related-articles -->
<footer>
{% include _footer.html %}
</footer>
Expand Down
1 change: 1 addition & 0 deletions theme-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ There are two rake tasks that can be used to create a new post or page with all
rake new_post

Enter a title for your post: My Awesome Post
Enter category name to group your post in (leave blank for none): blog
Enter tags to classify your post (comma separated): web development, code
Creating new post: _posts/2014-02-10-my-awesome-post.md
{% endhighlight %}
Expand Down

0 comments on commit 0cdcde1

Please sign in to comment.