Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add temporary templates to fix Docker build
- Loading branch information
Showing
8 changed files
with
766 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
This is a base page template. All the other template pages implement this interface. | ||
|
||
{% interface | ||
Page { | ||
Title() | ||
Body() | ||
} | ||
%} | ||
|
||
|
||
Page prints a page implementing Page interface. | ||
{% func PageTemplate(p Page) %} | ||
<html> | ||
<head> | ||
<title>{%= p.Title() %}</title> | ||
</head> | ||
<body> | ||
<div> | ||
<a href="/">return to main page</a> | ||
</div> | ||
{%= p.Body() %} | ||
</body> | ||
</html> | ||
{% endfunc %} | ||
|
||
|
||
Base page implementation. Other pages may inherit from it if they need | ||
overriding only certain Page methods | ||
{% code type BasePage struct {} %} | ||
{% func (p *BasePage) Title() %}This is a base title{% endfunc %} | ||
{% func (p *BasePage) Body() %}This is a base body{% endfunc %} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Error page template. Implements BasePage methods. | ||
|
||
{% code | ||
type ErrorPage struct { | ||
// inherit from base page, so its' title is used in error page. | ||
BasePage | ||
|
||
// error path | ||
Path []byte | ||
} | ||
%} | ||
|
||
|
||
{% func (p *ErrorPage) Body() %} | ||
<h1>Error page</h1> | ||
</div> | ||
Unsupported path <b>{%z p.Path %}</b>. | ||
</div> | ||
Base page body: {%= p.BasePage.Body() %} | ||
{% endfunc %} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Main page template. Implements BasePage methods. | ||
|
||
{% import "github.com/valyala/fasthttp" %} | ||
|
||
{% code | ||
type MainPage struct { | ||
CTX *fasthttp.RequestCtx | ||
} | ||
%} | ||
|
||
|
||
{% func (p *MainPage) Title() %} | ||
This is the main page | ||
{% endfunc %} | ||
|
||
|
||
{% func (p *MainPage) Body() %} | ||
<h1>Main page</h1> | ||
<div> | ||
Click links below: | ||
<ul> | ||
<li><a href="/table?rowsCount=42">Table page</a></li> | ||
<li><a href="/unknown-page">Error page</a></li> | ||
</ul> | ||
</div> | ||
<div> | ||
Some info about you:<br/> | ||
IP: <b>{%s p.CTX.RemoteIP().String() %}</b><br/> | ||
User-Agent: <b>{%z p.CTX.UserAgent() %}</b><br/> | ||
</div> | ||
{% endfunc %} |
Oops, something went wrong.