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
require "pro_tacts/admin/phlex"
require "pro_tacts/admin/layout"
require "pro_tacts/admin/record_card"
module ProTacts
module Admin
# GET /import — the screen an address book arrives on
# (docs/plans/2026-09-21-import-a-vcf.md): the file a Mac already
# knows how to export.
#
# The form takes one file: a .vcf, or the JSON Monica 4 exports an
# account as (Import::Monica), which is read as the .vcf it
# composes. Looking over what is in it needs the file open, so
# that is the walk's (Web#card_screen: the list of its contacts
# and the pair of cards a row there opens).
#
# Nothing comes back here at the end of a walk. What arrived is
# the group the import filed it under, a page that lists the same
# contacts and is still there tomorrow, so the walk ends on that
# rather than on a copy of it under this form (Web#close_walk).
class ImportUpload < Phlex::HTML
# @rbs @login: String
# @rbs @notice: String?
FORM = "import-form" #: String
private_constant :FORM
#: (login: String, ?notice: String?) -> void
def initialize(login:, notice: nil)
@login = login
@notice = notice
end
def view_template
render Layout.new(title: "Import", login: @login, notice: @notice) do
render RecordCard.new(heading: "Import contacts", submit: "Import", form: FORM) do
form(action: "/import", method: "post", enctype: "multipart/form-data", id: FORM) do
label(class: "field") do
plain "vcard file or Monica export"
input(type: "file", name: "vcf", accept: ".vcf,text/vcard,.json,application/json")
end
end
end
end
end
end
end
end