@fiduswriter/frontend 0.1.67 → 0.1.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +7 -0
  2. package/dist/app/index.d.ts.map +1 -1
  3. package/dist/app/index.js +2 -1
  4. package/dist/app/index.js.map +1 -1
  5. package/dist/user/auth/login.d.ts.map +1 -1
  6. package/dist/user/auth/login.js +2 -1
  7. package/dist/user/auth/login.js.map +1 -1
  8. package/dist/user/auth/signup.d.ts +3 -1
  9. package/dist/user/auth/signup.d.ts.map +1 -1
  10. package/dist/user/auth/signup.js +30 -1
  11. package/dist/user/auth/signup.js.map +1 -1
  12. package/dist/user/auth/social_icons.d.ts +2 -0
  13. package/dist/user/auth/social_icons.d.ts.map +1 -0
  14. package/dist/user/auth/social_icons.js +11 -0
  15. package/dist/user/auth/social_icons.js.map +1 -0
  16. package/locale/ar/messages.json +371 -357
  17. package/locale/bg/messages.json +371 -357
  18. package/locale/cs/messages.json +371 -357
  19. package/locale/da/messages.json +371 -357
  20. package/locale/de/messages.json +371 -357
  21. package/locale/en/messages.json +371 -357
  22. package/locale/en_US/messages.json +371 -357
  23. package/locale/es/messages.json +371 -357
  24. package/locale/fr/messages.json +371 -357
  25. package/locale/it/messages.json +371 -357
  26. package/locale/ja/messages.json +371 -357
  27. package/locale/ko/messages.json +371 -357
  28. package/locale/nb/messages.json +371 -357
  29. package/locale/nl/messages.json +371 -357
  30. package/locale/pl/messages.json +371 -357
  31. package/locale/pt_BR/messages.json +371 -357
  32. package/locale/pt_PT/messages.json +371 -357
  33. package/locale/ru/messages.json +371 -357
  34. package/locale/sv/messages.json +371 -357
  35. package/locale/tr/messages.json +371 -357
  36. package/locale/zh_Hans/messages.json +371 -357
  37. package/package.json +1 -1
  38. package/scripts/extract-i18n-generic.js +182 -139
  39. package/src/app/index.ts +3 -1
  40. package/src/user/auth/login.ts +2 -1
  41. package/src/user/auth/signup.ts +50 -1
  42. package/src/user/auth/social_icons.ts +10 -0
  43. package/scripts/extract-fwtoolkit-i18n.js +0 -230
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiduswriter/frontend",
3
- "version": "0.1.67",
3
+ "version": "0.1.68",
4
4
  "description": "Fidus Writer-specific shared utilities and UI chrome",
5
5
  "keywords": [
6
6
  "fiduswriter",
@@ -7,13 +7,25 @@
7
7
  * translations from a Django djangojs.po file (including obsolete #~ entries),
8
8
  * and writes per-language messages.po into locale/.
9
9
  *
10
+ * Translations already present in the target messages.po files are preserved,
11
+ * so re-running extraction never loses work done by translate_all.py or by
12
+ * human translators. All .po parsing handles msgids and msgstrs wrapped over
13
+ * multiple lines (polib and msgcat wrap long lines when saving) — a naive
14
+ * line-based parser silently drops every translation long enough to wrap.
15
+ *
10
16
  * Usage:
11
17
  * node scripts/extract-i18n.js <path-to-django-locale>
12
18
  */
13
19
 
14
- import { readFileSync, writeFileSync, mkdirSync, readdirSync, existsSync } from "node:fs"
15
- import { join, dirname } from "node:path"
16
- import { fileURLToPath } from "node:url"
20
+ import {
21
+ readFileSync,
22
+ writeFileSync,
23
+ mkdirSync,
24
+ readdirSync,
25
+ existsSync
26
+ } from "node:fs"
27
+ import {join, dirname} from "node:path"
28
+ import {fileURLToPath} from "node:url"
17
29
 
18
30
  const __dirname = dirname(fileURLToPath(import.meta.url))
19
31
  const root = join(__dirname, "..")
@@ -30,11 +42,20 @@ const msgids = new Set()
30
42
 
31
43
  function scanDir(dir) {
32
44
  if (!existsSync(dir)) return
33
- for (const entry of readdirSync(dir, { withFileTypes: true })) {
45
+ for (const entry of readdirSync(dir, {withFileTypes: true})) {
34
46
  const full = join(dir, entry.name)
35
- if (entry.isDirectory() && entry.name !== "node_modules" && !entry.name.startsWith(".")) {
47
+ if (
48
+ entry.isDirectory() &&
49
+ entry.name !== "node_modules" &&
50
+ !entry.name.startsWith(".")
51
+ ) {
36
52
  scanDir(full)
37
- } else if (entry.isFile() && (entry.name.endsWith(".ts") || entry.name.endsWith(".js") || entry.name.endsWith(".mjs"))) {
53
+ } else if (
54
+ entry.isFile() &&
55
+ (entry.name.endsWith(".ts") ||
56
+ entry.name.endsWith(".js") ||
57
+ entry.name.endsWith(".mjs"))
58
+ ) {
38
59
  const content = readFileSync(full, "utf8")
39
60
  let match
40
61
  while ((match = GETTEXT_RE.exec(content)) !== null) {
@@ -53,183 +74,185 @@ if (msgids.size === 0) {
53
74
  process.exit(0)
54
75
  }
55
76
 
56
- // Build translation maps from djangojs.po — including obsolete #~ entries
57
- const languages = readdirSync(djangoLocalePath, { withFileTypes: true })
58
- .filter((e) => e.isDirectory())
59
- .map((e) => e.name)
60
-
61
- console.log(`Looking up translations in ${languages.length} languages (including obsolete entries)...`)
62
-
63
- let totalTranslated = 0
64
-
65
- for (const lang of languages) {
66
- const poFile = join(djangoLocalePath, lang, "LC_MESSAGES", "djangojs.po")
67
- if (!existsSync(poFile)) continue
77
+ /**
78
+ * Parse the active (non-obsolete) entries of a .po file into a Map of
79
+ * msgid → {msgstr, comment}. Handles msgids and msgstrs wrapped over
80
+ * multiple lines. Entries with an empty msgstr and plural entries are
81
+ * skipped.
82
+ */
83
+ function parsePoEntries(content) {
84
+ const entries = new Map()
85
+ let msgid = null
86
+ let msgstr = ""
87
+ let comment = ""
88
+ let pendingComment = ""
89
+ let mode = null // null | "msgid" | "msgstr"
68
90
 
69
- const poContent = readFileSync(poFile, "utf8")
70
- const translationMap = new Map()
91
+ const flush = () => {
92
+ if (msgid && msgstr) {
93
+ entries.set(msgid, {msgstr, comment: comment.trim()})
94
+ }
95
+ msgid = null
96
+ msgstr = ""
97
+ comment = ""
98
+ mode = null
99
+ }
71
100
 
72
- // Parse active entries
73
- let currentMsgid = null
74
- let currentComment = ""
75
- for (const line of poContent.split("\n")) {
101
+ for (const line of content.split("\n")) {
76
102
  const trimmed = line.trim()
77
- // Skip obsolete lines for active parsing
78
- if (trimmed.startsWith("#~")) continue
79
-
80
- if (trimmed.startsWith("#:")) {
81
- if (currentMsgid === null) currentComment += line + "\n"
103
+ if (trimmed === "") {
104
+ flush()
105
+ pendingComment = ""
82
106
  continue
83
107
  }
84
- if (trimmed.startsWith("#,") || trimmed.startsWith("#.") || trimmed.startsWith("#|")) {
85
- if (currentMsgid === null) currentComment += line + "\n"
108
+ if (trimmed.startsWith("#~")) {
109
+ // Obsolete entries are handled by parseObsoleteEntries().
86
110
  continue
87
111
  }
88
- if (trimmed.startsWith("#") && !trimmed.startsWith("#:")) continue
89
- if (trimmed.startsWith('msgid "')) {
90
- currentMsgid = unescapePo(trimmed.slice(7, -1))
112
+ if (trimmed.startsWith("#")) {
113
+ if (msgid === null) pendingComment += line + "\n"
91
114
  continue
92
115
  }
93
116
  if (trimmed.startsWith("msgid ")) {
94
- currentMsgid = unescapePo(trimmed.slice(6))
117
+ flush()
118
+ comment = pendingComment
119
+ pendingComment = ""
120
+ mode = "msgid"
121
+ msgid = unescapePo(stripQuotes(trimmed.slice(6)))
95
122
  continue
96
123
  }
97
- if (trimmed.startsWith('msgstr "') && currentMsgid !== null) {
98
- const msgstr = unescapePo(trimmed.slice(8, -1))
99
- if (msgstr) translationMap.set(currentMsgid, { msgstr, comment: currentComment.trim() })
100
- currentMsgid = null
101
- currentComment = ""
102
- continue
103
- }
104
- if (trimmed.startsWith("msgstr ") && currentMsgid !== null) {
105
- const msgstr = unescapePo(trimmed.slice(7))
106
- if (msgstr) translationMap.set(currentMsgid, { msgstr, comment: currentComment.trim() })
107
- currentMsgid = null
108
- currentComment = ""
124
+ if (trimmed.startsWith("msgid_plural") || trimmed.startsWith("msgstr[")) {
125
+ msgid = null
126
+ mode = null
109
127
  continue
110
128
  }
111
- if (trimmed.startsWith("msgid_plural") || trimmed.startsWith("msgstr[")) {
112
- currentMsgid = null
113
- currentComment = ""
129
+ if (trimmed.startsWith("msgstr ")) {
130
+ if (msgid === null) continue
131
+ mode = "msgstr"
132
+ msgstr = unescapePo(stripQuotes(trimmed.slice(7)))
114
133
  continue
115
134
  }
116
- if (trimmed.startsWith('"') && currentMsgid !== null) {
117
- currentMsgid += unescapePo(trimmed.slice(1, -1))
135
+ if (trimmed.startsWith('"')) {
136
+ const fragment = unescapePo(stripQuotes(trimmed))
137
+ if (mode === "msgid") {
138
+ msgid += fragment
139
+ } else if (mode === "msgstr") {
140
+ msgstr += fragment
141
+ }
118
142
  }
119
143
  }
144
+ flush()
145
+ return entries
146
+ }
120
147
 
121
- // Also parse obsolete entries (#~ msgid ... #~ msgstr ...)
122
- // State machine: null = awaiting entry, "msgid" = building msgid, "msgstr" = building msgstr
123
- let obsState = null // null | "msgid" | "msgstr"
124
- let obsMsgid = "" // accumulating msgid (may span multiple #~ "..." lines)
125
- let obsMsgstr = "" // accumulating msgstr
126
- let obsPrevMsgid = null
148
+ /**
149
+ * Parse the obsolete (#~) entries of a .po file into a Map of
150
+ * msgid → {msgstr, comment}. These often still hold the translation of a
151
+ * string that was reworded slightly, so they seed new msgids as well.
152
+ */
153
+ function parseObsoleteEntries(content) {
154
+ const entries = new Map()
155
+ let state = null // null | "msgid" | "msgstr"
156
+ let msgid = ""
157
+ let msgstr = ""
158
+ let prevMsgid = null
127
159
 
128
- function saveObsolete() {
129
- if (obsMsgid && obsMsgstr && !translationMap.has(obsMsgid)) {
130
- translationMap.set(obsMsgid, { msgstr: obsMsgstr, comment: "" })
160
+ const flush = () => {
161
+ if (msgid && msgstr && !entries.has(msgid)) {
162
+ entries.set(msgid, {msgstr, comment: ""})
131
163
  }
132
- if (obsPrevMsgid && obsMsgstr && !translationMap.has(obsPrevMsgid)) {
133
- translationMap.set(obsPrevMsgid, { msgstr: obsMsgstr, comment: "" })
164
+ if (prevMsgid && msgstr && !entries.has(prevMsgid)) {
165
+ entries.set(prevMsgid, {msgstr, comment: ""})
134
166
  }
167
+ state = null
168
+ msgid = ""
169
+ msgstr = ""
170
+ prevMsgid = null
135
171
  }
136
172
 
137
- for (const line of poContent.split("\n")) {
173
+ for (const line of content.split("\n")) {
138
174
  const trimmed = line.trim()
139
-
140
- // ----------- start of obsolete msgid -----------
141
- if (trimmed.startsWith('#~ msgid "')) {
142
- saveObsolete() // save any previous entry
143
- obsState = "msgid"
144
- obsMsgid = unescapePo(trimmed.slice(10, -1))
145
- obsMsgstr = ""
146
- obsPrevMsgid = null
175
+ if (trimmed.startsWith('#~ msgid "') || trimmed.startsWith("#~ msgid ")) {
176
+ flush()
177
+ state = "msgid"
178
+ msgid = unescapePo(stripQuotes(trimmed.slice(9)))
147
179
  continue
148
180
  }
149
- // Also handle msgid without quotes (rare)
150
- if (trimmed.startsWith("#~ msgid ") && !trimmed.startsWith('#~ msgid "')) {
151
- saveObsolete()
152
- obsState = "msgid"
153
- obsMsgid = unescapePo(trimmed.slice(9))
154
- obsMsgstr = ""
155
- obsPrevMsgid = null
181
+ if (trimmed.startsWith('#~| msgid "') || trimmed.startsWith("#~| msgid ")) {
182
+ prevMsgid = unescapePo(stripQuotes(trimmed.slice(11)))
156
183
  continue
157
184
  }
158
- // ----------- previous msgid marker -----------
159
- if (trimmed.startsWith('#~| msgid "')) {
160
- obsPrevMsgid = unescapePo(trimmed.slice(12, -1))
185
+ if (
186
+ state === "msgid" &&
187
+ (trimmed.startsWith('#~ msgstr "') || trimmed.startsWith("#~ msgstr "))
188
+ ) {
189
+ state = "msgstr"
190
+ msgstr = unescapePo(stripQuotes(trimmed.slice(11)))
161
191
  continue
162
192
  }
163
- // ----------- start of obsolete msgstr -----------
164
- if (trimmed.startsWith('#~ msgstr "') && obsState === "msgid") {
165
- obsState = "msgstr"
166
- obsMsgstr = unescapePo(trimmed.slice(11, -1))
167
- // If the msgid is non-empty and this is a single-line msgstr, save immediately
168
- continue
169
- }
170
- if (trimmed.startsWith("#~ msgstr ") && obsState === "msgid" && !trimmed.startsWith('#~ msgstr "')) {
171
- obsState = "msgstr"
172
- obsMsgstr = unescapePo(trimmed.slice(10))
173
- continue
174
- }
175
- // ----------- multi-line continuation -----------
176
- if (trimmed.startsWith('#~ "') && obsState !== null) {
177
- const fragment = unescapePo(trimmed.slice(4, -1))
178
- if (obsState === "msgid") {
179
- obsMsgid += fragment
180
- } else if (obsState === "msgstr") {
181
- obsMsgstr += fragment
193
+ if (trimmed.startsWith('#~ "') && state !== null) {
194
+ const fragment = unescapePo(stripQuotes(trimmed.slice(4)))
195
+ if (state === "msgid") {
196
+ msgid += fragment
197
+ } else {
198
+ msgstr += fragment
182
199
  }
183
200
  continue
184
201
  }
185
- // ----------- end of entry (next #~ msgid or non-obsolete line) -----------
186
- if (obsState === "msgstr" && (trimmed.startsWith('#~ msgid') || !trimmed.startsWith("#~"))) {
187
- saveObsolete()
188
- obsState = null
189
- obsMsgid = ""
190
- obsMsgstr = ""
202
+ if (state === "msgstr" && !trimmed.startsWith("#~")) {
203
+ flush()
191
204
  }
192
205
  }
193
- // Save any trailing entry
194
- if (obsState === "msgstr") {
195
- saveObsolete()
206
+ flush()
207
+ return entries
208
+ }
209
+
210
+ // Build translation maps from djangojs.po — including obsolete #~ entries
211
+ const languages = readdirSync(djangoLocalePath, {withFileTypes: true})
212
+ .filter(e => e.isDirectory())
213
+ .map(e => e.name)
214
+
215
+ console.log(
216
+ `Looking up translations in ${languages.length} languages (including obsolete entries)...`
217
+ )
218
+
219
+ let totalTranslated = 0
220
+
221
+ for (const lang of languages) {
222
+ const poFile = join(djangoLocalePath, lang, "LC_MESSAGES", "djangojs.po")
223
+ if (!existsSync(poFile)) continue
224
+
225
+ const poContent = readFileSync(poFile, "utf8")
226
+ const translationMap = parsePoEntries(poContent)
227
+ for (const [key, value] of parseObsoleteEntries(poContent)) {
228
+ if (!translationMap.has(key)) translationMap.set(key, value)
196
229
  }
197
230
 
198
- // Build entries — merge existing translations from the target .po file
199
- // if it already exists, so translations added by translate_all.py or
200
- // manual editing are preserved across re-extractions.
231
+ // Merge existing translations from the target .po file so translations
232
+ // added by translate_all.py or manual editing are preserved across
233
+ // re-extractions.
201
234
  const existingPo = join(root, "locale", lang, "LC_MESSAGES", "messages.po")
202
235
  const existingTranslations = new Map()
203
236
  if (existsSync(existingPo)) {
204
- const existingContent = readFileSync(existingPo, "utf8")
205
- let curMsgid = null
206
- for (const line of existingContent.split("\n")) {
207
- const trimmed = line.trim()
208
- if (trimmed.startsWith('msgid "')) {
209
- curMsgid = unescapePo(trimmed.slice(7, -1))
210
- continue
211
- }
212
- if (trimmed.startsWith('msgstr "') && curMsgid !== null) {
213
- const ms = unescapePo(trimmed.slice(8, -1))
214
- if (ms) existingTranslations.set(curMsgid, ms)
215
- curMsgid = null
216
- continue
217
- }
218
- if (trimmed.startsWith('"') && curMsgid !== null) {
219
- curMsgid += unescapePo(trimmed.slice(1, -1))
220
- }
237
+ for (const [key, value] of parsePoEntries(
238
+ readFileSync(existingPo, "utf8")
239
+ )) {
240
+ existingTranslations.set(key, value.msgstr)
221
241
  }
222
242
  }
223
243
 
244
+ // Build entries
224
245
  const entries = []
225
246
  for (const msgid of msgids) {
226
247
  // Prefer existing translation over djangojs.po lookup (no synthetic comment)
227
248
  const existing = existingTranslations.get(msgid)
228
- const t = existing ? { msgstr: existing, comment: "" } : translationMap.get(msgid)
249
+ const t = existing
250
+ ? {msgstr: existing, comment: ""}
251
+ : translationMap.get(msgid)
229
252
  entries.push({
230
253
  msgid,
231
254
  msgstr: t ? t.msgstr : "",
232
- comment: t ? t.comment : "",
255
+ comment: t ? t.comment : ""
233
256
  })
234
257
  if (t?.msgstr) totalTranslated++
235
258
  }
@@ -245,11 +268,11 @@ for (const lang of languages) {
245
268
  '"Content-Type: text/plain; charset=UTF-8\\n"',
246
269
  `"Language: ${lang}\\n"`,
247
270
  '"Plural-Forms: nplurals=2; plural=(n != 1);\\n"',
248
- "",
271
+ ""
249
272
  ].join("\n")
250
273
 
251
274
  const body = entries
252
- .map((e) => {
275
+ .map(e => {
253
276
  let lines = ""
254
277
  if (e.comment && !e.comment.startsWith("# obsolete")) {
255
278
  lines += e.comment + "\n"
@@ -261,18 +284,38 @@ for (const lang of languages) {
261
284
  .join("")
262
285
 
263
286
  const langDir = join(root, "locale", lang, "LC_MESSAGES")
264
- mkdirSync(langDir, { recursive: true })
287
+ mkdirSync(langDir, {recursive: true})
265
288
  writeFileSync(join(langDir, "messages.po"), header + body, "utf8")
266
289
 
267
- const translated = entries.filter((e) => e.msgstr).length
268
- console.log(` ${lang}: ${entries.length} entries, ${translated} translated`)
290
+ const translated = entries.filter(e => e.msgstr).length
291
+ console.log(
292
+ ` ${lang}: ${entries.length} entries, ${translated} translated`
293
+ )
269
294
  }
270
295
 
271
296
  console.log(`\nTotal translated strings: ${totalTranslated}`)
272
297
 
273
298
  function escapePo(s) {
274
- return s.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r").replace(/\t/g, "\\t")
299
+ return s
300
+ .replace(/\\/g, "\\\\")
301
+ .replace(/"/g, '\\"')
302
+ .replace(/\n/g, "\\n")
303
+ .replace(/\r/g, "\\r")
304
+ .replace(/\t/g, "\\t")
275
305
  }
306
+
276
307
  function unescapePo(s) {
277
- return s.replace(/\\"/g, '"').replace(/\\n/g, "\n").replace(/\\r/g, "\r").replace(/\t/g, "\t").replace(/\\\\/g, "\\")
308
+ return s
309
+ .replace(/\\"/g, '"')
310
+ .replace(/\\n/g, "\n")
311
+ .replace(/\\r/g, "\r")
312
+ .replace(/\t/g, "\t")
313
+ .replace(/\\\\/g, "\\")
314
+ }
315
+
316
+ function stripQuotes(s) {
317
+ if (s.startsWith('"') && s.endsWith('"') && s.length >= 2) {
318
+ return s.slice(1, -1)
319
+ }
320
+ return s
278
321
  }
package/src/app/index.ts CHANGED
@@ -210,7 +210,9 @@ export class App {
210
210
  case "sign-up":
211
211
  returnValue = new Signup({
212
212
  app: this.config.app as PreloginApp,
213
- language: this.config.language || ""
213
+ language: this.config.language || "",
214
+ socialaccount_providers:
215
+ this.config.socialaccount_providers ?? []
214
216
  })
215
217
  break
216
218
  default:
@@ -1,5 +1,6 @@
1
1
  import {escapeText} from "fwtoolkit"
2
2
  import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
3
+ import {socialProviderIcon} from "./social_icons.js"
3
4
 
4
5
  export class LoginPage extends PreloginPage {
5
6
  socialaccount_providers: Array<Record<string, unknown>>
@@ -44,7 +45,7 @@ export class LoginPage extends PreloginPage {
44
45
  (provider: any) => `<li>
45
46
  <a title="${provider.name}" class="fw-button fw-socialaccount fw-${provider.id}"
46
47
  href="${provider.login_url}">
47
- <span class="fab fa-${provider.id}"></span>
48
+ <span class="fab fa-${socialProviderIcon(provider.id)}"></span>
48
49
  ${gettext("Login with")} ${provider.name}
49
50
  </a>
50
51
  </li>`
@@ -1,9 +1,21 @@
1
1
  import {escapeText} from "fwtoolkit"
2
2
  import {PreloginPage, type PreloginApp} from "../../prelogin/index.js"
3
+ import {socialProviderIcon} from "./social_icons.js"
3
4
 
4
5
  export class Signup extends PreloginPage {
5
- constructor({app, language}: {app: PreloginApp; language: string}) {
6
+ socialaccount_providers: Array<Record<string, unknown>>
7
+
8
+ constructor({
9
+ app,
10
+ language,
11
+ socialaccount_providers
12
+ }: {
13
+ app: PreloginApp
14
+ language: string
15
+ socialaccount_providers: Array<Record<string, unknown>>
16
+ }) {
6
17
  super({app, language})
18
+ this.socialaccount_providers = socialaccount_providers
7
19
  this.title = gettext("Signup")
8
20
  if (this.app.settings?.REGISTRATION_OPEN) {
9
21
  this.contents = `<div class="fw-login-left">
@@ -13,6 +25,26 @@ export class Signup extends PreloginPage {
13
25
  'Already have an account? Then please <a href="/" title="Login">login</a>.'
14
26
  )}
15
27
  </p>
28
+ ${
29
+ this.app.settings?.SOCIALACCOUNT_OPEN &&
30
+ this.socialaccount_providers.length
31
+ ? `<div class="socialaccount_ballot">
32
+ <ul class="socialaccount_providers">
33
+ ${this.socialaccount_providers
34
+ .map(
35
+ (provider: any) => `<li>
36
+ <a title="${provider.name}" class="fw-button fw-socialaccount fw-${provider.id}"
37
+ href="${provider.login_url}">
38
+ <span class="fab fa-${socialProviderIcon(provider.id)}"></span>
39
+ ${gettext("Sign up with")} ${provider.name}
40
+ </a>
41
+ </li>`
42
+ )
43
+ .join("")}
44
+ </ul>
45
+ </div>`
46
+ : ""
47
+ }
16
48
  </div>
17
49
  <div class="fw-login-right">
18
50
  <form>
@@ -53,6 +85,23 @@ export class Signup extends PreloginPage {
53
85
  bind(): void {
54
86
  super.bind()
55
87
 
88
+ const socialButtons = document.body.querySelectorAll(
89
+ ".fw-button.fw-socialaccount"
90
+ )
91
+ let btnWidth = 1
92
+
93
+ socialButtons.forEach((button: Element) => {
94
+ const theWidth = (button as HTMLElement).clientWidth
95
+ if (btnWidth < theWidth) {
96
+ btnWidth = theWidth
97
+ }
98
+ })
99
+ btnWidth += 15
100
+ socialButtons.forEach(
101
+ button =>
102
+ ((button as HTMLElement).style.width = `${btnWidth}px`)
103
+ )
104
+
56
105
  const signupSubmit = document.querySelector("#signup-submit")
57
106
 
58
107
  if (!this.app.settings?.REGISTRATION_OPEN || !signupSubmit) {
@@ -0,0 +1,10 @@
1
+ // Map social account provider ids to Font Awesome brand icon names.
2
+ // The allauth openid_connect provider stands for an arbitrary OpenID
3
+ // Connect identity provider (for example an LDAP bridge via Dex,
4
+ // Keycloak or authentik), for which Font Awesome has a generic icon.
5
+ export const socialProviderIcon = (providerId: string): string => {
6
+ const iconMap: Record<string, string> = {
7
+ openid_connect: "openid"
8
+ }
9
+ return iconMap[providerId] || providerId
10
+ }