~cadence/bibliogram

ref: d660c849411808d12f8ab75beac87d633491c6e2 bibliogram/src/site/pug/settings.pug -rw-r--r-- 5.7 KiB
d660c849Cadence Ember Fix shortcode fetching 10 months ago
                                                                                
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//- Needs constants, settings, csrf, status, message
- const ll = lang.get(settings.language)

mixin fieldset(name)
	fieldset
		legend= name
		.fieldset-contents
			block

mixin input(id, description, placeholder, disabled, list)
	.field-row
		label.description(for=id)= description
		input(type="text" dir="ltr" id=id name=id value=settings[id] placeholder=placeholder disabled=disabled list=`${id}-list`)
		if list
			datalist(id=`${id}-list`)
				each item in list
					option(value=item)

mixin checkbox(id, description, label, disabled)
	.field-row.checkbox-row
		label.description(for=id)= description
		input.checkbox(type="checkbox" id=id name=id checked=(settings[id] !== 0) disabled=disabled autocomplete="off")
		label.pill(for=id tabindex=(disabled ? null : 0) onkeypress=`[" ", "Enter"].includes(event.key) && this.click()`)= label
			span.fake-checkbox(class=ll.meta_direction)

mixin select(id, description, disabled, options)
	.field-row
		label.description(for=id)= description
		select(id=id name=id disabled=disabled)
			each option in options
				option(value=option.value selected=(option.value === settings[id]))= option.text

doctype html
html(dir=ll.meta_direction)
	head
		title= `${ll.t_settings} | Bibliogram`
		include includes/head
		script(src=getStaticURL("html", "/static/js/settings_message.js") type="module")
	body.settings-page
		if status && message
			.status-notice(class=status)= message
		main.settings
			form(action=returnAction method="post" enctype="application/x-www-form-urlencoded")
				input(type="hidden" name="csrf" value=csrf)

				h1.title= ll.t_settings

				+fieldset(ll.t_features)
					+select("language", ll.t_language, false, [
						{value: "ar", text: "العربية"},
						{value: "bg", text: "Български"},
						{value: "de", text: "Deutsch"},
						{value: "en", text: "English (International)"},
						{value: "en-us", text: "English (US)"},
						{value: "es", text: "Español"},
						{value: "fa", text: "فارسي"},
						{value: "fr", text: "Français"},
						{value: "gl", text: "Galego"},
						{value: "id", text: "Bahasa Indonesia"},
						{value: "it", text: "Italiano"},
						{value: "ms", text: "Bahasa Melayu"},
						{value: "pl", text: "Polski"},
						{value: "ru", text: "Русский"},
						{value: "tr", text: "Türkçe"}
					])

					+select("save_data", ll.save_data, true, [
						{value: "automatic", text: ll.t_automatic},
						{value: "off", text: ll.t_off},
						{value: "lazy_load", text: ll.lazy_load},
						{value: "full", text: ll.t_full}
					])

					+input("rewrite_youtube", ll.rewrite_youtube, constants.default_user_settings.rewrite_youtube, false, [
						"invidio.us",
						"invidious.snopyta.org",
						"invidious.13ad.de",
						"watch.nettohikari.com",
						"invidious.fdn.fr",
						"yewtu.be"
					])

					+input("rewrite_twitter", ll.rewrite_twitter, constants.default_user_settings.rewrite_twitter, false, [
						"nitter.net",
						"nitter.snopyta.org",
						"nitter.pussthecat.org",
						"nitter.42l.fr",
						"nitter.mastodont.cat",
						"nitter.tedomum.net",
						"nitter.cattube.org",
						"nitter.fdn.fr",
						"nitter.1d4.us"
					])

					+checkbox("remove_trailing_hashtags", ll.remove_trailing_hashtags, ll.t_hide, false)

					+checkbox("link_hashtags", ll.link_hashtags, ll.t_clickable, true)

					+checkbox("show_comments", ll.show_comments, ll.t_display, true)

					+checkbox("spa", ll.fast_navigation, ll.t_enabled, false)

					+select("infinite_scroll", ll.infinite_scroll, true, [
						{value: "normal", text: ll.t_normal},
						{value: "eager", text: ll.t_eager},
						{value: "off", text: ll.t_manual}
					])

				+fieldset(ll.t_appearance)
					+select("theme", ll.t_theme, false, constants.themes.collated.map(entry => ({value: entry.file, text: entry.name})))

					+checkbox("display_top_nav", ll.display_top_nav, ll.t_always, false)

					+select("timeline_columns", ll.timeline_columns, false, [
						{value: "dynamic", text: ll.t_dynamic},
						{value: "three", text: ll.three_columns},
						{value: "four", text: ll.four_columns},
						{value: "six", text: ll.six_columns}
					])

					+select("caption_side", ll.caption_side, false, [
						{value: "left", text: ll.left_caption},
						{value: "right", text: ll.right_caption}
					])

					+checkbox("display_alt", ll.display_alt_text, ll.t_display, false)

				//- div
					//- Here are all the possible input styles. Uncomment to test styling.
					- let i = 2
					- let id = 0
					- let thisID
					while --i >= 0
						fieldset
							legend Style demo
							.field-row
								- thisID = "in"+(id++)
								label.description(for=thisID) Placeholder
								input(type="text" placeholder="Placeholder" id=thisID)

							.field-row
								- thisID = "in"+(id++)
								label.description(for=thisID) Disabled
								input(type="text" disabled placeholder="Disabled" value="Value" id=thisID)

							.field-row
								label.description Button
								button(type="button") Button

							.field-row
								- thisID = "in"+(id++)
								label.description(for=thisID) Select
								select(id=thisID)
									option Select
									option Yes
									option No
									option Always
									option Never

							.field-row.checkbox-row
								- thisID = "in"+(id++)
								label.description(for=thisID) Checkbox
								input.checkbox(type="checkbox" id=thisID)
								label.pill(for=thisID tabindex=0 onkeypress=`[" ", "Enter"].includes(event.key) && this.click()`) Label
									span.fake-checkbox

				if token
					p!= ll.pug_restore_sync_settings({token})

				.action-container
					span.home-link-container: a(href=returnURL).home-link= `← ${ll.t_return}`
					button(type="submit" formaction=stayAction).save-button= ll.t_save
					button(type="submit").save-button= ll.save_and_return