Skip to content

Commit

Permalink
made days configurable, writes to sandbox:out by default
Browse files Browse the repository at this point in the history
  • Loading branch information
houshuang committed Apr 16, 2012
1 parent 3b903ef commit a4e076f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions idealog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,30 @@

# get date month year

Days = 8 # how many days back, usually 1 is appropriate

def bname(ary)
ary.map {|f| File.basename(f).remove(".txt") }
end

bib = json_bib

clips = bname(`find /wiki/data/pages/clip/*.txt -mtime -1`.split("\n"))
notes = bname(`find /wiki/data/pages/notes/*.txt -mtime -1`.split("\n"))
clips = bname(`find /wiki/data/pages/clip/*.txt -mtime -#{Days}`.split("\n"))
notes = bname(`find /wiki/data/pages/notes/*.txt -mtime -#{Days}`.split("\n"))

pages = `find #{Wiki_path}/data/pages -mtime -1 -type f`.split("\n")
pages = `find #{Wiki_path}/data/pages -mtime -#{Days} -type f`.split("\n")
directories = %r[/(ref|notes|skimg|kindle|clip|kbib|abib|jbib|idealog|sandbox|test|bib)/]
pages.reject! {|f| f.match(directories) && f[-4..-1] == ".txt"}
pages.map! {|f| capitalize_word(f.remove("#{Wiki_path}/data/pages").gsubs(["/",":"], [".txt", " "], ["_", " "])) }

out = "h1. Idea log #{Time.now.strftime("%A %B %d, %Y")}\n\nh2. Notes\n\n"
out << "h2. Notes modified last 24 hours\n\n"
out << "h2. Notes modified last #{Days} day(s)\n\n"
notes.each { |x| out << " * [@#{x}]\n" }

out << "\nh2. Clips added without notes last 24 hours\n\n"
out << "\nh2. Clips added without notes last #{Days} day(s)\n\n"
(clips - notes).each { |x| out << " * [@#{x}]\n" }

out << "\nh2. Pages modified within last 24 hours\n\n"
out << "\nh2. Pages modified within last #{Days} day(s)\n\n"
pages.each {|x| out << " * [[#{x}]]\n"}

puts out
File.write(ARGV[0] || "/wiki/data/pages/sandbox/out.txt", out)

0 comments on commit a4e076f

Please sign in to comment.