File: songs.lua

package info (click to toggle)
lua-orbit 2.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 1,956 kB
  • ctags: 638
  • sloc: sql: 78; sh: 32; makefile: 31; xml: 20
file content (45 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env wsapi.cgi

local orbit = require"orbit"
local cosmo = require"cosmo"

local songs = orbit.new()

function songs.index(web)
   local songlist = {
      "Sgt. Pepper's Lonely Hearts Club Band",
      "With a Little Help from My Friends",
      "Lucy in the Sky with Diamonds",
      "Getting Better",
      "Fixing a Hole",
      "She's Leaving Home",
      "Being for the Benefit of Mr. Kite!",
      "Within You Without You",
      "When I'm Sixty-Four",
      "Lovely Rita",
      "Good Morning Good Morning",
      "Sgt. Pepper's Lonely Hearts Club Band (Reprise)",
      "A Day in the Life"
   }
   return songs.layout(songs.render_index({ songs = songlist }))
end

songs:dispatch_get(songs.index, "/")

function songs.layout(inner_html)
  return html{
    head{ title"Song List" },
    body{ inner_html }
  }
end

orbit.htmlify(songs, "layout")

songs.render_index = cosmo.compile[[
	 <h1>Songs</h1>
	    <table>
	    $songs[=[<tr><td>$it</td></tr>]=]
	 </table>  
      ]]

return songs.run