Browse code

added stringex gem for permalink url generation

Pavel Pravosud authored on 20/08/2011 at 03:24:15
Showing 3 changed files
... ...
@@ -10,3 +10,4 @@ gem 'haml', '>= 3.1'
10 10
 gem 'compass', '>= 0.11'
11 11
 gem 'rubypants'
12 12
 gem 'rb-fsevent'
13
+gem 'stringex'
13 14
\ No newline at end of file
... ...
@@ -40,6 +40,7 @@ GEM
40 40
       blankslate (>= 2.1.2.3)
41 41
       ffi (~> 1.0.7)
42 42
     sass (3.1.5)
43
+    stringex (1.3.0)
43 44
     syntax (1.0.0)
44 45
 
45 46
 PLATFORMS
... ...
@@ -56,3 +57,4 @@ DEPENDENCIES
56 56
   rb-fsevent
57 57
   rdiscount
58 58
   rubypants
59
+  stringex
... ...
@@ -1,5 +1,6 @@
1 1
 require "rubygems"
2 2
 require "bundler/setup"
3
+require "stringex"
3 4
 
4 5
 ## -- Rsync Deploy config -- ##
5 6
 # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
... ...
@@ -63,7 +64,7 @@ task :new_post, :title do |t, args|
63 63
   require './plugins/titlecase.rb'
64 64
   args.with_defaults(:title => 'new-post')
65 65
   title = args.title
66
-  filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.downcase.gsub(/&/,'and').gsub(/[,'":\?!\(\)\[\]]/,'').gsub(/[\W\.]/, '-').gsub(/-+$/,'')}.#{new_post_ext}"
66
+  filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
67 67
   puts "Creating new post: #{filename}"
68 68
   open(filename, 'w') do |post|
69 69
     system "mkdir -p #{source_dir}/#{posts_dir}";