Skip to content

Instantly share code, notes, and snippets.

View ThomasLocke's full-sized avatar

Thomas Løcke ThomasLocke

  • Loecke K/S
  • Denmark
View GitHub Profile
@ThomasLocke
ThomasLocke / gist:6568439
Created September 15, 2013 06:17
Using the Ada Web Server (AWS), part 2 - snippet 10
Dispatcher.Register (URI => "/helloworld.tmpl",
Action => Hello_World.Hello_World_Template'Access);
@ThomasLocke
ThomasLocke / gist:6568434
Created September 15, 2013 06:15
Using the Ada Web Server (AWS), part 2 - snippet 9
@@--
@@-- First we define a macro.
@@--
@@MACRO(F)@@
<span style="font-style: italic;">F</span><span style="font-size: 60%;">@_$1_@</span>
@@END_MACRO@@
@@--
@@-- And then comes the actual HTML5 document
@@--
<!DOCTYPE html>
@ThomasLocke
ThomasLocke / gist:6568413
Created September 15, 2013 06:10
Using the Ada Web Server (AWS), part 2 - snippet 8
procedure Append (T : in out Tag; Value : String);
procedure Append (T : in out Tag; Value : Character);
procedure Append (T : in out Tag; Value : Boolean);
procedure Append (T : in out Tag; Value : Unbounded_String);
procedure Append (T : in out Tag; Value : Integer);
procedure Append (T : in out Tag; Value : Tag);
@ThomasLocke
ThomasLocke / gist:6568410
Created September 15, 2013 06:10
Using the Ada Web Server (AWS), part 2 - snippet 7
for i in Fibs'Range loop
case i is
when 0 => Fibs (i) := 0;
when 1 => Fibs (i) := 1;
when others => Fibs (i) := Fibs (i - 1) + Fibs (i - 2);
end case;
Append (Position, i);
Append (Fibonacci, Fibs (i));
end loop;
@ThomasLocke
ThomasLocke / gist:6568402
Created September 15, 2013 06:09
Using the Ada Web Server (AWS), part 2 - snippet 6
with AWS.Messages;
with AWS.Templates;
package body Hello_World is
-- Stuff...
------------------------
-- Generate_Content --
------------------------
@ThomasLocke
ThomasLocke / gist:6568396
Created September 15, 2013 06:07
Using the Ada Web Server (AWS), part 2 - snippet 5
return AWS.Response.Build
(Content_Type => AWS.MIME.Text_HTML,
Message_Body => Parse ("templates/not_found.tmpl", Translations),
Status_Code => AWS.Messages.S404);
@ThomasLocke
ThomasLocke / gist:6568394
Created September 15, 2013 06:06
Using the Ada Web Server (AWS), part 2 - snippet 4
function Parse
(Filename : String;
Translations : Translate_Set;
Cached : Boolean := False;
Keep_Unknown_Tags : Boolean := False;
Lazy_Tag : Dyn.Lazy_Tag_Access := Dyn.Null_Lazy_Tag;
Cursor_Tag : Dyn.Cursor_Tag_Access := Dyn.Null_Cursor_Tag)
return String;
@ThomasLocke
ThomasLocke / gist:6568386
Created September 15, 2013 06:02
Using the Ada Web Server (AWS), part 2 - snippet 3
with AWS.Messages;
with AWS.MIME;
with AWS.Response;
with AWS.Status;
with AWS.Templates;
package body Not_Found is
-- Stuff...
@ThomasLocke
ThomasLocke / gist:6568376
Created September 15, 2013 06:01
Using the Ada Web Server (AWS), part 2 - snippet 2
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Not found</title>
</head>
<body>
<h1>Not found</h1>
<p>Resource @_RESOURCE_@ not found</p>
</body>
@ThomasLocke
ThomasLocke / gist:6568363
Created September 15, 2013 05:58
Using the Ada Web Server (AWS), part 2 - snippet 1
$ git clone git://github.com/ThomasLocke/AWS_Tutorial_2.git