lib/runeblog.rb in runeblog-0.0.12 vs lib/runeblog.rb in runeblog-0.0.13

- old
+ new

@@ -1,8 +1,8 @@ class RuneBlog - VERSION = "0.0.12" + VERSION = "0.0.13" Path = File.expand_path(File.join(File.dirname(__FILE__))) DefaultData = Path + "/../data" BlogHeader = File.read(DefaultData + "/blog_header.html") rescue "not found" @@ -62,11 +62,11 @@ ### next_sequence def next_sequence @config.sequence += 1 - File.open("data/sequence", "w") {|f| f.puts @config.sequence } + File.open("#{@config.root}/data/sequence", "w") {|f| f.puts @config.sequence } @config.sequence end ### make_slug @@ -320,17 +320,22 @@ end ### list_posts def list_posts - Dir.chdir("#{@config.root}/views/#@view/") - system("ls -d 0*") - puts + dir = "#{@config.root}/views/#@view/" + Dir.chdir(dir) do + posts = Dir.entries(".").grep(/^0.*/) + puts + if posts.empty? + puts "No posts" + else + posts.each {|post| puts " #{post}" } + end + puts + end +rescue + puts "Oops? cwd = #{Dir.pwd} dir = #{dir}" + exit end - -### templates - -class RuneBlog - -end