import stuff back from pandoc
This commit is contained in:
parent
7daae052f6
commit
85e9ec60ba
|
@ -0,0 +1,24 @@
|
||||||
|
sqlite3 = require "lsqlite3"
|
||||||
|
|
||||||
|
db = assert sqlite3.open "../db/posts.db"
|
||||||
|
|
||||||
|
update_stmt = assert db\prepare "UPDATE Posts SET mdown=? WHERE id=?"
|
||||||
|
|
||||||
|
db\exec [[ BEGIN TRANSACTION; ]]
|
||||||
|
|
||||||
|
for post in db\nrows "SELECT * FROM Posts"
|
||||||
|
with fout = io.open "../raw/posts/#{post.id}.textile.md", "r"
|
||||||
|
unless fout
|
||||||
|
db\exec [[ ROLLBACK; ]]
|
||||||
|
error "can't open #{post.id}.textile.md"
|
||||||
|
|
||||||
|
body = fout\read("*a")
|
||||||
|
|
||||||
|
do
|
||||||
|
update_stmt\bind_values body, tonumber(post.id)
|
||||||
|
update_stmt\step!
|
||||||
|
update_stmt\reset!
|
||||||
|
|
||||||
|
fout\close!
|
||||||
|
|
||||||
|
db\exec [[ COMMIT; ]]
|
Loading…
Reference in New Issue