@@ -91,7 +91,8 @@ extension Unidoc.RefsTable.Row.Graph:HTML.OutputStreamable
91
91
} = " ( \( size >> 10 ) kb) "
92
92
}
93
93
94
- guard self . view. editor
94
+ // You need to be logged-in to see the menu.
95
+ guard self . view. authenticated
95
96
else
96
97
{
97
98
return
@@ -102,70 +103,89 @@ extension Unidoc.RefsTable.Row.Graph:HTML.OutputStreamable
102
103
$0 [ . button] = " ••• "
103
104
$0 [ . ul]
104
105
{
105
- $0 [ . li ]
106
+ if self . view . editor
106
107
{
107
- $0 [ . form ]
108
+ $0 [ . li ]
108
109
{
109
- $0. enctype = " \( MediaType . application ( . x_www_form_urlencoded) ) "
110
- $0. action = " \( Unidoc . Post [ . build, confirm: true ] ) "
111
- $0. method = " post "
112
- } = Unidoc . BuildFormTool. init (
113
- form: . init( symbol: self . symbol, action: . submit) ,
114
- area: . init( text: nil , type: . inline) )
110
+ $0 [ . form]
111
+ {
112
+ $0. enctype = " \( MediaType . application ( . x_www_form_urlencoded) ) "
113
+ $0. action = " \( Unidoc . Post [ . build, confirm: true ] ) "
114
+ $0. method = " post "
115
+ } = Unidoc . BuildFormTool. init (
116
+ form: . init( symbol: self . symbol, action: . submit) ,
117
+ area: . init( text: nil , type: . inline) )
118
+ }
115
119
}
116
120
117
121
guard
118
- case . administratrix? = self . view. global,
119
122
case . some( let graph) = self . state
120
123
else
121
124
{
122
125
return
123
126
}
124
127
125
- for (label , route ) : ( String , Unidoc . LinkerRoute ) in [
126
- ( " Uplink " , . uplink ) ,
127
- ( " Unlink " , . unlink ) ,
128
- ( " Delete " , . delete ) ,
129
- ]
128
+ let object : Unidoc . GraphPath = . init ( edition : graph . id , type : . bson_zz )
129
+
130
+ // For now, allow all logged-in users to obtain the download link.
131
+ // This only makes sense in production.
132
+ if self . view . enforced
130
133
{
131
134
$0 [ . li]
132
135
{
133
- var action : URI = Unidoc . ServerRoot. link / " \( route) "
134
-
135
- switch route
136
- {
137
- // Uplink does not require confirmation.
138
- case . uplink: break
139
- case . unlink: action [ " y " ] = " false "
140
- case . delete: action [ " y " ] = " false "
141
- }
142
-
143
- $0 [ . form]
136
+ $0 [ . a]
144
137
{
145
- $0. enctype = " \( MediaType . application ( . x_www_form_urlencoded) ) "
146
- $0. action = " \( action) "
147
- $0. method = " post "
148
- } = Unidoc . LinkerTool. init (
149
- form: . init( edition: graph. id,
150
- back: " \( Unidoc . RefsEndpoint [ self . symbol. package ] ) " ) ,
151
- name: label)
138
+ $0. target = " _blank "
139
+ $0. rel = . external
140
+ $0. href = " https://static.swiftinit.org \( object) "
141
+ } = " Download "
152
142
}
153
143
}
154
144
155
- $0 [ . li ]
145
+ if self . view . admin
156
146
{
157
- $0 [ . a ]
147
+ $0 [ . li ]
158
148
{
159
- let path : Unidoc . GraphPath = . init( edition: graph. id,
160
- type: . bson_zz)
161
-
162
- $0. target = " _blank "
163
- $0. rel = . external
164
- $0. href = """
165
- https://s3.console.aws.amazon.com/s3/object/symbolgraphs \
166
- ?region=us-east-1&bucketType=general&prefix= \( path. prefix)
167
- """
168
- } = " Inspect object "
149
+ $0 [ . a]
150
+ {
151
+ $0. target = " _blank "
152
+ $0. rel = . external
153
+ $0. href = """
154
+ https://s3.console.aws.amazon.com/s3/object/symbolgraphs \
155
+ ?region=us-east-1&bucketType=general&prefix= \( object. prefix)
156
+ """
157
+ } = " Inspect object "
158
+ }
159
+
160
+ for (label, route) : ( String , Unidoc . LinkerRoute ) in [
161
+ ( " Uplink " , . uplink) ,
162
+ ( " Unlink " , . unlink) ,
163
+ ( " Delete " , . delete) ,
164
+ ]
165
+ {
166
+ $0 [ . li]
167
+ {
168
+ var action : URI = Unidoc . ServerRoot. link / " \( route) "
169
+
170
+ switch route
171
+ {
172
+ // Uplink does not require confirmation.
173
+ case . uplink: break
174
+ case . unlink: action [ " y " ] = " false "
175
+ case . delete: action [ " y " ] = " false "
176
+ }
177
+
178
+ $0 [ . form]
179
+ {
180
+ $0. enctype = " \( MediaType . application ( . x_www_form_urlencoded) ) "
181
+ $0. action = " \( action) "
182
+ $0. method = " post "
183
+ } = Unidoc . LinkerTool. init (
184
+ form: . init( edition: graph. id,
185
+ back: " \( Unidoc . RefsEndpoint [ self . symbol. package ] ) " ) ,
186
+ name: label)
187
+ }
188
+ }
169
189
}
170
190
}
171
191
}
0 commit comments