~xdavidwu/xdavidwu.link

0cdcde10bfd1605ce16b6dcaee5a71238f868f46 — Michael Rose 10 years ago 938c653
Add category to rake new_post
5 files changed, 6 insertions(+), 20 deletions(-)

M .gitignore
D Gemfile
M Rakefile.rb
M _layouts/post.html
M theme-setup.md
M .gitignore => .gitignore +1 -2
@@ 4,5 4,4 @@ _site
*.sublime-workspace
codekit-config.json
node_modules
_asset_bundler_cache
Gemfile.lock
\ No newline at end of file
_asset_bundler_cache
\ No newline at end of file

D Gemfile => Gemfile +0 -8
@@ 1,8 0,0 @@
source 'https://rubygems.org'

gem 'jekyll'
gem 'kramdown'
gem 'coderay'
gem 'rake'
gem 'activesupport'
gem 'stringex'
\ No newline at end of file

M Rakefile.rb => Rakefile.rb +2 -0
@@ 25,6 25,7 @@ task :new_post, :title do |t, args|
  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|


@@ 32,6 33,7 @@ task :new_post, :title do |t, args|
    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: "

M _layouts/post.html => _layouts/post.html +2 -10
@@ 40,23 40,15 @@
</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>

M theme-setup.md => theme-setup.md +1 -0
@@ 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 %}