~otheb/kb

ref: 4db1fe839491601333a63eb991c1f57db2c91b02 kb/kb-web/main.d -rw-r--r-- 18.3 KiB View raw
4db1fe83Olie Ayre Added "static-dir" option to WUI 2 months ago
                                                                                
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
module kbweb ;

import std.stdio     ;
import std.json      ;
import std.file      ;
import std.algorithm ;
import std.uri       ;
import std.conv      ;
import std.array     ;
import std.string    ;
import std.typecons  ;
import std.socket    ;

import lighttp    ;
import arsd.http2 ;

import declhtml ;

// default config file
const string CONFFILE = "/etc/kb-web/config" ;
// basic settings
ushort PORT         = 80               ;
string FRIENDLYNAME = "KB Web UI"      ;
bool   LIGHTTHEME   = false            ;
string SERVER       = "localhost:8000" ;
string STATICDIR    = "./static"       ;

int main( string[] args ) {
	// read config
	// if an argument is provided, that is used as the config file
	// config file will softly default to /etc/kbw/config
	if ( args.length > 2 ) {
		writeln( "Usage: " , args[0] , " [CONFIG FILE]" ) ;
		return 1 ;
	} else if ( args.length == 2 ) {
		if ( ! exists( args[1] ) ) {
			writeln( "Config file " , args[1] ,
			         " does not exist or cannot be found" ) ;
			return 1 ;
		} else if ( isDir( args[1] ) ) {
			writeln( "Config file " , args[1] , " is a directory" ) ;
			return 1 ;
		}
		readconf( args[1].readText() ) ;
	}
	if ( exists( CONFFILE ) ) //
	if ( isFile( CONFFILE ) ) { readconf( CONFFILE.readText() ) ; }

	// display config options on startup
	writeln( "              Port : " , PORT ) ;
	writeln( "     Friendly name : " , FRIENDLYNAME ) ;
	writeln( "   Use light theme : " , LIGHTTHEME ) ;
	writeln( "        API server : " , SERVER ) ;
	writeln( "Static content dir : " , STATICDIR ) ;

	Server server = new Server() ;
	server.host( "0.0.0.0" , PORT ) ;
	server.host( "::" , PORT ) ;
	server.router.add( new router() ) ;
	server.router.add( Get( "global.css" ) , new Resource( "text/css" ,
	                   readText( buildPath( STATICDIR , "global.css" ) ) ) ) ;
	server.router.add( Get( "light.css" ) , new Resource( "text/css" ,
	                   readText( buildPath( STATICDIR , "light.css" ) ) ) ) ;
	server.router.add( Get( "dark.css" ) , new Resource( "text/css" ,
	                   readText( buildPath( STATICDIR , "dark.css" ) ) ) ) ;
	server.run() ;
	return 0 ;
}

void readconf( string content ) {
	auto j = content.parseJSON() ;
	if ( ( "port" in j ) !is null ) { PORT = cast(ushort)j["port"].integer ; }
	if ( ( "friendly-name" in j ) !is null ) {
		FRIENDLYNAME = j["friendly-name"].str ;
	}
	if ( ( "light-theme" in j ) !is null ) {
		LIGHTTHEME = j["light-theme"].boolean ;
	}
	if ( ( "server" in j ) !is null ) { SERVER = j["server"].str ; }
	if ( ( "static-dir" in j ) !is null ) { STATICDIR = j["static-dir"].str ; }
}

string fmtdate( long ts ) {
	import std.datetime ;
	auto dt = cast(DateTime)SysTime.fromUnixTime( ts , LocalTime() ) ;
	return text( // D Month YEAR @ HH:MMap
		dt.day , " " , // day
		[ "" , "January" , "February" , "March" , "April" , "May" , "June" ,
		  "July" , "August" , "September" , "October" , "November" , "December"
		][ dt.month ] , " " , // month
		dt.year , " @ " , // year
		dt.hour % 12 == 0 ? 12 : dt.hour % 12 , ":" , // hour
		std.conv.to!string( dt.minute ).rightJustify( 2 , '0' ) , // minute
		dt.hour >= 12 ? "pm" : "am" // am/pm
	) ;
}

class entry {
	long     id      ;
	string   title   ;
	string[] tags    ;
	string   time    ;
	bool     old     ;
	string   content ;
	Tuple!( string , string )[] history ; // [0] is time, [1] is content

	this( long i , string t , string[] tg , long ts , bool o , string c ,
	      Tuple!( long , string )[] h ) {
		id      = i            ;
		title   = t            ;
		tags    = tg           ;
		time    = ts.fmtdate() ;
		old     = o            ;
		content = c            ;
		history = h.map!( e => tuple( e[0].fmtdate() , e[1] ) ).array ;
	}

	this( long i , string t , string[] tg , bool o , string c ) {
		id      = i  ;
		title   = t  ;
		tags    = tg ;
		old     = o  ;
		content = c  ;
	}
}

auto getindex() { return get( "http://" ~ SERVER ~ "/" ).waitForCompletion() ; }
auto getentry( long id ) {
	return get( "http://" ~ SERVER ~ "/" ~ id.to!string ).waitForCompletion() ;
}
auto getentry( string id ) {
	return get( "http://" ~ SERVER ~ "/" ~ id ).waitForCompletion() ;
}
auto getsearch( string[] terms ) {
	return new HttpClient().request(
		Uri( "http://" ~ SERVER ~ "/s" ) ,
		HttpVerb.POST ,
		cast(ubyte[])JSONValue( [ "search" : JSONValue( terms.join( " " ) ) ] )
			.toString() ,
		"application/json"
	).waitForCompletion() ;
}
auto postnew( string j ) {
	return new HttpClient().request( Uri( "http://" ~ SERVER ~ "/" ) ,
	                                 HttpVerb.POST , cast(ubyte[])j ,
	                                 "application/json" ).waitForCompletion() ;
}
auto postedit( string j , string id ) {
	return new HttpClient().request( Uri( "http://" ~ SERVER ~ "/" ~ id ) ,
	                                 HttpVerb.POST , cast(ubyte[])j ,
	                                 "application/json" ).waitForCompletion() ;
}
auto patchedit( string j , string id ) {
	return new HttpClient().request( Uri( "http://" ~ SERVER ~ "/" ~ id ) ,
	                                 HttpVerb.PATCH , cast(ubyte[])j ,
	                                 "application/json" ).waitForCompletion() ;
}
auto deleteentry( string id ) {
	return new HttpClient().request( Uri( "http://" ~ SERVER ~ "/" ~ id ) ,
	                                 HttpVerb.DELETE ).waitForCompletion() ;
}

auto noapi() {
	return mkdoc(
		makehead( "No API connection - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			makeactionbar() ,
			// non-breaking space to add the gap between the search bar and the
			// results below that is present on the homepage
			"\u00a0" ,
			div(
				h2( "502 Bad Gateway - No API connection" ) ,
				p( "No connection could be made to the API server at http://" ,
				   SERVER , ". Make sure it's running on that host, " ,
				   "configured to listen at that port, and that there are no " ,
				   "firewall rules preventing access to it." )
			)
		)
	) ;
}

auto notfound() {
	return mkdoc(
		makehead( "Not found - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			makeactionbar() ,
			// non-breaking space to add the gap between the search bar and the
			// results below that is present on the homepage
			"\u00a0" ,
			div(
				h2( "404 Not Found" ) ,
				p( "The requested entry does not exist." )
			)
		)
	) ;
}

class router {
	@Get( "" )
	index( ServerRequest req , ServerResponse res ) {
		writeln( "GET /" ) ;

		// check whether we're sorting by recency
		bool sortrecent = req.url.queryParams["sort"].canFind( "recent" ) ;

		// get entries
		HttpResponse apires ;
		try {
			apires = getindex() ;
		} catch ( SocketOSException ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		entry[] entries = apires.contentText.parseJSON()["ids"].array
			.map!( i => getentry( i.integer ) ).filter!( r => r.code == 200 )
			.map!( r => r.contentText.parseJSON() ).array.sort!( ( a , b ) =>
				sortrecent ? a["time"].integer > b["time"].integer :
					a["id"].integer < b["id"].integer
			).map!( e => e.fromjson() ).array ;

		res.status = StatusCodes.ok ;
		res.body = makeindex( entries , sortrecent ) ;
	}

	@Get( "entry" , "([0-9]+)" )
	entrypage( ServerRequest req , ServerResponse res , string id ) {
		writeln( "GET /entry/" , id ) ;

		// get the entry
		HttpResponse apires ;
		try {
			apires = getentry( id ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		if ( apires.code == 404 ) {
			writeln( "Entry doesn't exist" ) ;
			res.status = StatusCodes.notFound ;
			res.body = notfound() ;
			return ;
		}
		auto e = apires.fromjson() ;

		res.status = StatusCodes.ok ;
		res.body = makeentry( e ) ;
	}

	@Get( "search" )
	searchpage( ServerRequest req , ServerResponse res ) {
		auto terms = req.url.queryParams["s"].join( "+" ).split( "+" )
		             .filter!( t => t.length ).array ;
		writeln( "GET /search : " , terms ) ;

		// make the API request
		HttpResponse apires ;
		try {
			apires = getsearch( terms ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}

		// get entries
		entry[] entries = apires.contentText.parseJSON()["results"].array
			.map!( r => tuple( r["id"].integer , r["relevance"].integer ) )
			.array.sort!( ( a , b ) => a[1] > b[1] )
			.map!( r => getentry( r[0] ) ).filter!( r => r.code == 200 )
			.map!( r => r.contentText.parseJSON().fromjson ).array ;

		res.status = StatusCodes.ok ;
		res.body = makeresults( entries , terms.join( " " ) ) ;
	}

	@Get( "new" )
	createpage( ServerRequest req , ServerResponse res ) {
		res.body = makeeditpage() ;
	}
	@Post( "new" )
	handlecreate( ServerRequest req , ServerResponse res ) {
		// get parameters
		auto items = getparams( req.body ) ;
		writeln( "Creating new entry with data : " , items ) ;

		// build json
		auto j = JSONValue( [
			"title"   : JSONValue( items["title"] ) ,
			"old"     : JSONValue( ( "old" in items ) !is null ) ,
			"tags"    : JSONValue( items.get( "tags" , "" ).split()
			                       .filter!( t => t != "" ).array ) ,
			"content" : JSONValue( items["content"] )
		] ).toString() ;

		// make API request
		HttpResponse apires ;
		try {
			apires = postnew( j ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		auto newentry = apires.contentText.parseJSON()["id"].integer.to!string ;

		// redirect to new entry page
		writeln( "Made new entry " , newentry , ", redirecting" ) ;
		res.status = StatusCodes.seeOther ;
		res.headers["Location"] = "/entry/" ~ newentry ;
	}

	@Get( "edit" , "([0-9]+)" )
	editpage( ServerRequest req , ServerResponse res , string id ) {
		// get existing entry
		HttpResponse apires ;
		try {
			apires = getentry( id ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		if ( apires.code != 200 ) {
			res.status = StatusCodes.notFound ;
			res.body = notfound() ;
			return ;
		}

		auto e = apires.fromjson() ;

		res.body = makeeditpage( true , e ) ;
	}
	@Post( "edit" , "([0-9]+)" )
	handleedit( ServerRequest req , ServerResponse res , string id ) {
		auto items = getparams( req.body ) ;
		writeln( "Editing entry with data : " , items ) ;

		// build json
		auto j = JSONValue( [
			"title" : JSONValue( items["title"] ) ,
			"old"   : JSONValue( ( "old" in items ) !is null ) ,
			"tags"  : JSONValue( items.get( "tags" , "" ).split()
			                     .filter!( t => t != "" ).array ) ,
			"content" : JSONValue( items["content"] )
		] ).toString() ;

		// make API request
		HttpResponse apires ;
		try { apires = ( "ispatch" in items ) !is null ?
		             patchedit( j , id ) : postedit( j , id ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		auto newentry = apires.contentText.parseJSON()["id"].integer.to!string ;

		// redirect to new entry page
		writeln( "Edited entry " , newentry , ", redirecting" ) ;
		res.status = StatusCodes.seeOther ;
		res.headers["Location"] = "/entry/" ~ newentry ;
	}

	@Get( "delete" , "([0-9]+)" )
	deletepage( ServerRequest req , ServerResponse res , string id ) {
		// get existing entry
		HttpResponse apires ;
		try {
			apires = getentry( id ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		if ( apires.code != 200 ) {
			res.status = StatusCodes.notFound ;
			res.body = notfound() ;
			return ;
		}

		auto t = apires.fromjson().title ;
		res.body = makedeletepage( id , t ) ;
	}
	@Post( "delete" , "([0-9]+)" )
	handledelete( ServerRequest req , ServerResponse res , string id ) {
		// make api request
		HttpResponse apires ;
		try {
			apires = deleteentry( id ) ;
		} catch ( SocketOSException e ) {
			res.status = StatusCodes.badGateway ;
			res.body = noapi() ;
			return ;
		}
		if ( apires.code != 200 ) {
			res.status = StatusCodes.notFound ;
			res.body = notfound() ;
			return ;
		}

		res.body = makedeletedpage( id ) ;
	}
}

string[string] getparams( string q ) {
	string[string] items ;
	foreach ( string param ; q.split( "&" ) ) {
		Tuple!( string , string ) kv = param.split( "=" )[0..2] ;
		items[ kv[0] ] = kv[1].tr( "+" , " " ).decodeComponent()
			// we split lines and join again to remove nasty CRLF line endings
			.splitLines().join( "\n" ) ;
	}
	// adjust parameters for better formatting
	items["title"] = items["title"].tr( "\n" , " " ) ;
	string[] lines ;
	foreach ( string l ; items["content"].splitLines() ) {
		l = l.stripRight() ;
		while ( l.startsWith( "    " ) && l.length > 4 ) {
			l = "\t" ~ l[4..$] ;
		}
		lines ~= l ;
	}
	items["content"] = lines.join( "\n" ).wrap( 80 ) ;
	return items ;
}

entry fromjson( JSONValue j ) {
	return new entry(
		j["id"].integer ,
		j["title"].str ,
		j["tags"].array.map!( t => t.str ).array ,
		j["time"].integer ,
		j["old"].boolean ,
		j["content"].str ,
		j["history"].array.map!( h =>
			tuple( h["time"].integer , h["content"].str )
		).array.sort!( ( a , b ) => a[0] > b[0] ).array
	) ;
}
entry fromjson( HttpResponse r ) {
	return r.contentText.parseJSON().fromjson() ;
}

string makeindex( entry[] entries , bool recent ) {
	return mkdoc(
		makehead( FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			makeactionbar() ,
			"Sort by " ,
			( recent ? a( "/?sort=id" , "ID" ) : a( "/?sort=recent" , "time" ) )
				.class_( "sort" ) ,
			" instead." ,
			entries.length == 0
			? [ div( p( "No entries found" ).class_( "middle" ) ) ]
			: entries.map!( e => makecard( e ) ).array
		)
	) ;
}

string makeresults( entry[] entries , string terms ) {
	return mkdoc(
		makehead( "Search results for \"" ~ terms ~ "\" - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			makeactionbar() ,
			// non-breaking space to add the gap between the search bar and the
			// results below that is present on the homepage
			"\u00a0" ,
			entries.length == 0
			? [ div( p( "No entries found" ).class_( "middle" ) ) ]
			: entries.map!( e => makecard( e ) ).array
		)
	) ;
}

auto makehead( string t ) {
	return head( charset() , style( "/global.css" ) ,
	             style( LIGHTTHEME ? "/light.css" : "/dark.css" ) ,
	             title( t ) ) ;
}

auto makeactionbar( bool extras = false , long id = 0 ) {
	return div(
		form( "/search" , input().attr( "type" , "text" )
		      .attr( "name" , "s" ).attr( "placeholder" , "Search" ) )
			.id( "search" ) ,
		form( "/new" , input().attr( "type" , "submit" ).attr( "value" , "+" ) )
			.id( "create" ) ,
		extras == false ? [] : [
			form( "/edit/" ~ id.text , input().attr( "type" , "submit" )
			      .attr( "value" , "Edit" ) ).id( "edit" ) ,
			form( "/delete/" ~ id.text , input().attr( "type" , "submit" )
			      .attr( "value" , "Delete" ) ).id( "delete" )
		]
	).id( "actionbar" ) ;
}

auto makecard( entry e ) {
	return div(
		h2(
			span( "#" , e.id.text , " " ).class_( "id" ) ,
			a( "/entry/" ~ e.id.text ,
				e.old ? "[DEPRECATED] " : "" ,
				e.title
			).class_( "entry" ) ,
		) ,
		span( e.time ).class_( "datetime" ) ,
		e.tags.map!( t => a( "/search?s=" ~ t , t ).class_( "tag" ) ).array
	) ;
}

string makeentry( entry e ) {
	return mkdoc(
		makehead( "#" ~ e.id.text ~ " " ~ e.title ~ " - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			makeactionbar( true , e.id ) ,
			// non-breaking space to add the gap between the search bar and the
			// entry below that is present on the homepage
			"\u00a0" ,
			div(
				h2( span( "#" , e.id.text , " " ).class_( "id" ) ,
					e.old ? "[DEPRECATED] " : "" ,
					e.title ) ,
				span ( e.time ).class_( "datetime" ) ,
				e.tags.map!( t =>
					a( "/search?s=" ~ t , t ).class_( "tag" )
				).array ,
				pre( e.content )
			) ,
			e.history.length == 0
			? div( p( "No history" ).class_( "middle" ) )
			: div(
				label( "Show/hide history" ).attr( "for" , "history-toggle" ) ,
				input().attr( "type" , "checkbox" ).id( "history-toggle" ) ,
				div( e.history.map!( h => [ div( h[0] , pre( h[1] ) ) ] )
					.join( hr ).array ).id( "history-view" )
			)
		)
	) ;
}

string makeeditpage( bool editing = false , entry e = null ) {
	string title = editing ?
	               "Editing entry #" ~ e.id.text ~ " '" ~ e.title ~ "'" :
	               "Create a new entry" ;
	return mkdoc(
		makehead( title ~ " - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			div(
				h2( title ) ,
				form( editing ? "/edit/" ~ e.id.text : "/new" ,
					span( "Title" ).class_( "label" ) ,
					input().attr( "type" , "text" ).attr( "name" , "title" )
						.attr( "value" , editing ? e.title : "" )
						.attr( "placeholder" , "Title" )
						.attr( "required" , "" ) , br ,
					span( "Tags" ).class_( "label" ) ,
					input().attr( "type" , "text" ).attr( "name" , "tags" )
						.attr( "value" , editing ? e.tags.join( " " ) : "" )
						.attr( "placeholder" , "first second third" ) , br ,
					span( "Deprecated" ).class_( "label" ) ,
					editing && e.old ?
					input().attr( "type" , "checkbox" ).attr( "name" , "old" )
						.attr( "checked" , "" ) :
					input().attr( "type" , "checkbox" ).attr( "name" , "old" ) ,
					br ,
					editing ? span( "Is Patch" ).class_( "label" ) : nothing ,
					editing ? input().attr( "type" , "checkbox" )
						.attr( "name" , "ispatch" ) : nothing ,
					editing ? br : nothing ,
					textarea( editing ? e.content : "" )
						.attr( "name" , "content" ).attr( "cols" , "80" )
						.attr( "placeholder" , "Message content" )
						.attr( "required" , "" ) ,
					input().attr( "type" , "submit" ).attr( "value" , "Submit" )
				).id( "form" ).attr( "method" , "post" )
			)
		)
	) ;
}

string makedeletepage( string id , string title ) {
	return mkdoc(
		makehead( "Delete entry '" ~ title ~ "' - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			div(
				h2( "Delete entry #" ~ id ~ " '" ~ title ~ "'" ) ,
				p( "Are you sure you want to delete entry #" , id , "? " ,
				   "This will be immediate and cannot be undone." ) ,
				form( "/entry/" ~ id ,
					input().attr( "type" , "submit" ).attr( "value" , "Cancel" )
						.id( "cancel" )
				).id( "inline" ) ,
				form( "/delete/" ~ id ,
					input().attr( "type" , "submit" ).attr( "value" , "Delete" )
						.id( "delete" )
				).attr( "method" , "post" ).id( "inline" )
			)
		)
	) ;
}

string makedeletedpage( string id ) {
	return mkdoc(
		makehead( "Entry deleted - " ~ FRIENDLYNAME ) ,
		body(
			h1( a( "/" , FRIENDLYNAME ) ) ,
			div(
				h2( "Entry deleted" ) ,
				p( a( "/" , "Back to index" ) )
			)
		)
	) ;
}