summaryrefslogtreecommitdiff
path: root/views/head.pug
blob: 9c248a464dc52145f460912e14799baddcd191f6 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//- vim:ts=4:sw=4:

meta(name="viewport" content="width=device-width,initial-scale=1")
link(rel="icon" type="image/svg+xml" href="/favicon.svg")
link(rel="stylesheet" href="/fonts/fonts.css")
link(rel="stylesheet" href="/style.css")

mixin social(title,description,game)
	meta(property="og:title" content=title)
	meta(property="og:type" content="website")
	if game
		meta(property="og:image" content=SITE_URL+"/"+game+"/cover.2x.jpg")
	else
		meta(property="og:image" content=SITE_URL+"/images/rally-the-troops.png")
	meta(property="og:description" content=description)

mixin gamecover(title_id)
	a(href="/"+title_id)
		img(src=`/${title_id}/cover.1x.jpg` srcset=`/${title_id}/cover.2x.jpg 2x`)

mixin forumpost(row,show_buttons)
	.post
		.head
			.from: a(href="/user/"+row.author_name)= row.author_name
			.time= row.ctime
				if row.edited
					|
					| (edited #{row.mtime})
		.body!= row.body
	if show_buttons && user
		.edit
			if row.author_id === user.user_id
				| #[a(href="/forum/edit/"+row.post_id) Edit]
				|
			| #[a(href="/forum/reply/"+row.post_id) Reply]

mixin gametable(status,table,hide_title=0)
	table
		thead
			tr
				th ID
				unless hide_title
					th Title
				th Scenario
				th Players
				th Description
				case status
					when 0
						th Created
					when 1
						th Changed
						th Turn
					when 2
						th Finished
						th Result
				th
		tbody
			each row in table
				tr
					td: a(href="/join/"+row.game_id)= row.game_id
					unless hide_title
						td.w: a(href="/"+row.title_id)= row.title_name
					if true
						td= row.scenario
					else
						td= row.options !== "None" ? row.scenario + ", " + row.options : row.scenario
					if row.player_names
						td!= row.player_names
					else
						td.error Nobody
					td= row.description
					case status
						when 0
							td.w= row.ctime
						when 1
							td.w= row.mtime
							if (row.is_active)
								td.is_active= row.active
							else
								td= row.active
						when 2
							td.w= row.mtime
							td= row.result
					td.command
						if status === 0
							if row.is_ready
								a(href="/join/"+row.game_id) Enter
							else
								a(href="/join/"+row.game_id) Join
						else if status === 1
							if row.is_yours
								if row.is_shared
									a(href="/join/"+row.game_id) Play
								else
									a(href=`/${row.title_id}/play:${row.game_id}:${row.your_role}`) Play
							else
								a(href=`/${row.title_id}/play:${row.game_id}`) View
						else if status >= 2
							if row.is_yours
								if row.is_shared
									a(href="/join/"+row.game_id) View
								else
									a(href=`/${row.title_id}/play:${row.game_id}:${row.your_role}`) View
							else
								a(href=`/${row.title_id}/replay:${row.game_id}`) View
			else
				tr
					case status
						when 0
							td(colspan=7-hide_title) No open games.
						when 1
							td(colspan=8-hide_title) No active games.
						when 2
							td(colspan=8-hide_title) No finished games.