Thanks. I will fix this up and then you can see the changes in Mercurial and then we can discuss this. This is a good exercise to understand how things work. I probably won't have time to work on this before Saturday.
I haven't worked with this code in a long time, so I made some changes to conform to what I do now. In particular I now use longs for IDs. This change breaks the database, so delete your current lucene.
You don't need to put everything in do-end blocks. I use these blocks for small chunks of independent code to make this clear.
I changed your Post.luan to only add to my Post.luan . This is critical if modules will be combined. If code is replicated than modules can conflict.
I added Post.reply() and Thread.new_thread() to clean up the code. This also makes the code more extensible. And this eliminates the need for your Reply_page.luan which can be deleted.
Your code makes clear that my Thread_page.respond() is overcomplicated. In particular my "unread" code is useless in the threaded case. I should probably make an "unread" module which shouldn't be combined with "threaded_replies". Then we can see how to clean up this part.