Skip to content

Commit 9c7e7bc

Browse files
committed
use y=false to trigger confirmation
1 parent f056c53 commit 9c7e7bc

File tree

4 files changed

+24
-39
lines changed

4 files changed

+24
-39
lines changed

Sources/UnidocServer/Requests/Unidoc.Router.swift

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ extension Unidoc
2121
private
2222
var stem:ArraySlice<String>
2323
private
24+
let path:URI.Path
25+
private
2426
let query:URI.Query
2527

2628
private
@@ -30,13 +32,15 @@ extension Unidoc
3032
origin:IP.Origin,
3133
host:String?,
3234
stem:ArraySlice<String>,
35+
path:URI.Path,
3336
query:URI.Query)
3437
{
3538
self.headers = headers
3639
self.authorization = authorization
3740
self.origin = origin
3841
self.host = host
3942
self.stem = stem
43+
self.path = path
4044
self.query = query
4145
}
4246
}
@@ -51,6 +55,7 @@ extension Unidoc.Router
5155
origin: request.origin.ip,
5256
host: request.host,
5357
stem: request.path,
58+
path: request.uri.path,
5459
query: request.uri.query ?? [:])
5560
}
5661
}
@@ -500,20 +505,20 @@ extension Unidoc.Router
500505
}
501506

502507
private mutating
503-
func link(form query:URI.Query) -> Unidoc.AnyOperation?
508+
func link(form queryPayload:URI.Query) -> Unidoc.AnyOperation?
504509
{
505510
guard
506511
let route:Unidoc.LinkerRoute = self.descend(),
507-
let form:Unidoc.LinkerForm = .init(from: query)
512+
let form:Unidoc.LinkerForm = .init(from: queryPayload)
508513
else
509514
{
510515
return nil
511516
}
512517

513-
if let path:URI.Path = form.next
518+
for case ("y", "false") in self.query.parameters
514519
{
515520
let page:Unidoc.ReallyPage
516-
let uri:URI = .init(path: path, query: query)
521+
let uri:URI = .init(path: self.path, query: queryPayload)
517522

518523
switch route
519524
{
@@ -524,19 +529,17 @@ extension Unidoc.Router
524529

525530
return .syncHTML(page)
526531
}
527-
else
528-
{
529-
let action:Unidoc.LinkerAction
530532

531-
switch route
532-
{
533-
case .uplink: action = .uplinkRefresh
534-
case .unlink: action = .unlink
535-
case .delete: action = .delete
536-
}
533+
let action:Unidoc.LinkerAction
537534

538-
return .unordered(Unidoc.LinkerOperation.init(action: action, form: form))
535+
switch route
536+
{
537+
case .uplink: action = .uplinkRefresh
538+
case .unlink: action = .unlink
539+
case .delete: action = .delete
539540
}
541+
542+
return .unordered(Unidoc.LinkerOperation.init(action: action, form: form))
540543
}
541544

542545
private mutating

Sources/UnidocUI/Endpoints/Tags/Unidoc.LinkerForm.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@ extension Unidoc
99
let edition:Edition
1010
public
1111
let back:String
12-
public
13-
let next:URI.Path?
1412

1513
@inlinable public
16-
init(edition:Edition, back:String, next:URI.Path? = nil)
14+
init(edition:Edition, back:String)
1715
{
1816
self.edition = edition
1917
self.back = back
20-
self.next = next
2118
}
2219
}
2320
}
@@ -26,7 +23,6 @@ extension Unidoc.LinkerForm
2623
static var package:String { "package" }
2724
static var version:String { "version" }
2825
static var back:String { "back" }
29-
static var next:String { "next" }
3026

3127
public
3228
init?(parameters:borrowing [String: String])
@@ -42,8 +38,6 @@ extension Unidoc.LinkerForm
4238
return nil
4339
}
4440

45-
self.init(edition: .init(package: package, version: version),
46-
back: back,
47-
next: parameters[Self.next].map(URI.Path.init(_:)) ?? nil)
41+
self.init(edition: .init(package: package, version: version), back: back)
4842
}
4943
}

Sources/UnidocUI/Endpoints/Tags/Unidoc.LinkerTool.swift

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,6 @@ extension Unidoc.LinkerTool:HTML.OutputStreamable
3939
$0.value = self.form.back
4040
}
4141

42-
if let next:URI.Path = self.form.next
43-
{
44-
form[.input]
45-
{
46-
$0.type = "hidden"
47-
$0.name = Unidoc.LinkerForm.next
48-
$0.value = "\(next)"
49-
}
50-
}
51-
5242
form[.button] { $0.type = "submit"; $0.class = "text" } = self.name
5343
}
5444
}

Sources/UnidocUI/Endpoints/Tags/Unidoc.RefsTable.Row.Graph.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,14 @@ extension Unidoc.RefsTable.Row.Graph:HTML.OutputStreamable
130130
{
131131
$0[.li]
132132
{
133-
let action:URI = Unidoc.ServerRoot.link / "\(route)"
134-
let next:URI.Path?
133+
var action:URI = Unidoc.ServerRoot.link / "\(route)"
135134

136135
switch route
137136
{
138137
// Uplink does not require confirmation.
139-
case .uplink: next = nil
140-
case .unlink: next = action.path
141-
case .delete: next = action.path
138+
case .uplink: break
139+
case .unlink: action["y"] = "false"
140+
case .delete: action["y"] = "false"
142141
}
143142

144143
$0[.form]
@@ -148,8 +147,7 @@ extension Unidoc.RefsTable.Row.Graph:HTML.OutputStreamable
148147
$0.method = "post"
149148
} = Unidoc.LinkerTool.init(
150149
form: .init(edition: graph.id,
151-
back: "\(Unidoc.RefsEndpoint[self.symbol.package])",
152-
next: next),
150+
back: "\(Unidoc.RefsEndpoint[self.symbol.package])"),
153151
name: label)
154152
}
155153
}

0 commit comments

Comments
 (0)