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
require "pro_tacts/admin/phlex"
require "pro_tacts/admin/layout"
module ProTacts
module Admin
# GET /setup — the screen a device installs the CardDAV account
# from, so the device that can reach the app provisions itself
# rather than being mailed a profile rendered on a checkout.
#
# /setup rather than /profile: in a web app a profile is the reader's
# own account page, and this is the device's setup — the one thing
# somebody types after the hostname when a new phone arrives.
#
# The account it names is read off the request rather than out of
# the environment (see Web's route), so the two facts worth stating
# — which server, under which name — are the ones the download is
# about to carry, not a copy of them.
class DeviceSetup < Phlex::HTML
# @rbs @hostname: String
# @rbs @login: String
# @rbs @name: String
#: (hostname: String, login: String, name: String) -> void
def initialize(hostname:, login:, name:)
@hostname = hostname
@login = login
@name = name
end
def view_template
render Layout.new(title: "Device setup", login: @login) do
div(class: "record") do
div(class: "record-nav") do
a(href: "/", class: "type-label") { "‹ contacts" }
end
div(class: "card") do
div(class: "card-body") do
h1(class: "type-h2") { "CardDAV profile" }
dl(class: "detail-grid") do
dt(class: "type-label") { "server" }
dd(class: "type-body-sm") { @hostname }
dt(class: "type-label") { "account" }
dd(class: "type-body-sm") { @name }
end
a(href: "/setup/carddav.mobileconfig", class: "btn", data_variant: "primary") {
"download profile"
}
end
end
end
end
end
end
end
end