Permalink
Browse files

Made it look for the template within the gem, not inside the .ljpost …

…directory.
  • Loading branch information...
dagbrown authored and Dave Brown committed Oct 3, 2007
1 parent 19ac3bb commit 2fcd76a9fb4420bd0038b56135d49843f3470d51
Showing with 18 additions and 3 deletions.
  1. +18 −3 bin/ljpost
View
@@ -1,20 +1,28 @@
#!/opt/bin/ruby
-LJPOSTDIR=ENV["HOME"]+"/.ljpost"
+LJPOSTDIR=File.join(ENV["HOME"],"/.ljpost")
+
+if not File.exists?(LJPOSTDIR)
+ Dir.mkdir(LJPOSTDIR)
+ Dir.mkdir File.join(LJPOSTDIR,"outgoing")
+ Dir.mkdir File.join(LJPOSTDIR,"sent")
+end
require "tempfile"
require "yaml"
require "time"
+template=File.join(File.dirname(File.dirname(__FILE__)),"template")
+
t=Tempfile.new("ljpost")
-t.write(File.read("#{LJPOSTDIR}/template"))
+t.write(File.read(template))
t.close
+
system(ENV["VISUAL"],t.path)
fh=File.open(t.path,File::RDONLY)
text=fh.read
-# (headertext,bodytext)=t.read.split(/^--------$/,2);
(headertext,bodytext)=text.split(/^--text follows this line--$/,2);
headers=Hash.new
headertext.split(/\n/).each do |line|
@@ -29,6 +37,13 @@ else
headers["Date"]=Time.now
end
+# convert "Preformatted" boolean tag to actual boolean
+headers["Preformatted"] = {
+ ?t => true,
+ ?y => true,
+ ?f => false,
+ ?n => false } [ headers["Preformatted"].downcase[0] ]
+
File.open("#{LJPOSTDIR}/outgoing/"+headers["Date"].strftime("%Y%m%d%H%M%S"),
"w") do |f|
f.write(headers.to_yaml)

0 comments on commit 2fcd76a

Please sign in to comment.