Skip to content

Commit 09c3c82

Browse files
committed
move to octopress
1 parent da9978b commit 09c3c82

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

move.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
2-
32
BLOG_DIR = "."
4-
TARGET_DIR = "/data/workspace/haliblog-octopress/source/_posts"
3+
TARGET_DIR = "/data/workspace/octopress/"
54

65
FORMAT = """
76
---
@@ -48,14 +47,17 @@ def move
4847
cmd = %{cat "#{title}.rst"| pandoc -f rst -t markdown}
4948
text = `#{cmd}`
5049
# code
51-
text = text.strip.gsub(/~~~~/, "```").gsub(/~~~~ {.sourceCode .(\w+)}/, '```\1')
50+
text = text.strip
51+
.gsub(/~~~~ {\.sourceCode .([^\}]+)}/, '```\1')
52+
.gsub(/~~~~/, "```")
53+
.gsub("```lisp", "```")
5254
# first line image need a space
5355
text.sub!(/\n/, "\n\n") if text.start_with? "![image]"
5456

5557
header = FORMAT % {title: title, created: created}
56-
File.open("#{TARGET_DIR}/#{created.split[0]}-#{MAPED_TITLE[title]}.markdown", "w+").write("#{header}\n#{text}")
58+
target = title.start_with?("_") ? "#{TARGET_DIR}/t" : "#{TARGET_DIR}/source/_posts"
59+
File.open("#{target}/#{created.split[0]}-#{MAPED_TITLE[title]}.markdown", "w+").write("#{header}\n#{text}")
5760
end
5861
end
5962

6063
move()
61-

0 commit comments

Comments
 (0)