annotate examples/blog/test.luan @ 1255:4f571a974132

replace Thread.schedule with Thread.once and Thread.repeating
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 03 Sep 2018 06:13:55 -0600
parents 7d4b5afb636f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
693
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
1 local Luan = require "luan:Luan.luan"
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local to_string = Luan.to_string or error()
693
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
4 local Http = require "luan:http/Http.luan"
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
5 local Http_test = require "luan:http/Http_test.luan"
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local init = Http_test.init or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local get_page = Http_test.get_page or error()
693
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
8 local Io = require "luan:Io.luan"
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local print = Io.print or error()
693
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
10 local String = require "luan:String.luan"
629
35dde32c02ab change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents: 598
diff changeset
11 local matches = String.matches or error()
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
693
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
13 local Db = require "site:/lib/Db.luan"
1224
Franklin Schmidt <fschmidt@gmail.com>
parents: 1220
diff changeset
14 Db.db = Db.new("site:/private/local/lucene_test")
1220
4721c482c86b cleaner Db example
Franklin Schmidt <fschmidt@gmail.com>
parents: 1218
diff changeset
15 Db.db.delete_all()
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16
693
ca169567ce07 module URIs must now include ".luan"
Franklin Schmidt <fschmidt@gmail.com>
parents: 629
diff changeset
17 local Post = require "site:/lib/Post.luan"
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 local page
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 print 'go'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 print '/'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 get_page '/'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 init()
1218
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
27 print '/new.html'
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
28 get_page '/new.html'
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 init()
1152
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
31 Http.request.parameters.subject = 'test'
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
32 Http.request.parameters.content = 'this is a test'
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
33 Http.request.parameters.save = 'whatever'
1218
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
34 print '/new.html submit'
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
35 get_page '/new.html'
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 local posts = Post.get_all()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 #posts == 1 or error()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 local post_id = to_string(posts[1].id)
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 init()
1152
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
41 Http.request.parameters.post = post_id
1218
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
42 print '/edit.html'
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
43 get_page '/edit.html'
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 init()
1152
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
46 Http.request.parameters.post = post_id
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
47 Http.request.parameters.subject = 'test'
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
48 Http.request.parameters.content = 'this is an edit'
21d157b153fe change http parameters interface
Franklin Schmidt <fschmidt@gmail.com>
parents: 779
diff changeset
49 Http.request.parameters.save = 'whatever'
1218
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
50 print '/edit.html submit'
a50803fde972 http/tools cleanup
Franklin Schmidt <fschmidt@gmail.com>
parents: 1152
diff changeset
51 get_page '/edit.html'
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
52
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 init()
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
54 print '/ again'
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 page = get_page '/'
629
35dde32c02ab change String.matches()
Franklin Schmidt <fschmidt@gmail.com>
parents: 598
diff changeset
56 matches(page,'this is an edit') or error()
598
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
57
e930f92d0f61 add blog test
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 print 'done'