mirror of
https://github.com/kataras/iris.git
synced 2025-12-26 14:27:04 +00:00
7.0.1 - https://github.com/iris-contrib/community-board/issues/1 https://github.com/iris-contrib/community-board/issues/2
Read HISTORY.md Former-commit-id: 82df2d266055818ffafe0ba66b58cf4ed9089922
This commit is contained in:
@@ -6,6 +6,8 @@ So it's useless for the end-developers, but it will be a good place to learn how
|
||||
cli and dynamic-generators programs.
|
||||
|
||||
|
||||
Click [here](https://github.com/iris-contrib/community-board/issues/2) to learn its future.
|
||||
|
||||
> When I use the word "generator" I don't mean the go1.4+ generate feature.
|
||||
|
||||
## Don't waste your time, it is not ready yet.
|
||||
|
||||
@@ -1,133 +0,0 @@
|
||||
# Examples generate command
|
||||
|
||||
## Running methods
|
||||
|
||||
### Build and run each time
|
||||
```sh
|
||||
$ cd $GOPATH/src/github.com/kataras/iris/internal/cmd
|
||||
$ go run main.go gen website examples >> recipe_content.html
|
||||
```
|
||||
|
||||
### Using an executable
|
||||
```sh
|
||||
$ cd $GOPATH/src/github.com/kataras/iris/internal/cmd
|
||||
$ go build
|
||||
# rename the binary, executable file, to something like "iris" or "iris.exe" for win
|
||||
# copy it to your systems folder or to the $GOPATH/bin
|
||||
```
|
||||
And use that command instead:
|
||||
```sh
|
||||
$ iris gen website examples >> recipe_content.html
|
||||
```
|
||||
> That executable can be copied and used anywhere.
|
||||
|
||||
## Action
|
||||
|
||||
This command should write to the argument output `>>` or print to the `os.Stdout` something like this:
|
||||
```html
|
||||
<h2 id="Beginner"><a href="#Beginner" class="headerlink" title="Beginner"></a>Beginner</h2>
|
||||
<h3 id="Hello-World"><a href="#Hello-World" class="headerlink" title="Hello World"></a>Hello World</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/hello-world/main.go" data-visible="true" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Overview"><a href="#Overview" class="headerlink" title="Overview"></a>Overview</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/overview/main.go" data-visible="true" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Internal-Application-File-Logger"><a href="#Internal-Application-File-Logger" class="headerlink" title="Internal Application File Logger"></a>Internal
|
||||
Application File Logger</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/file-logger/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Write-JSON"><a href="#Write-JSON" class="headerlink" title="Write JSON"></a>Write JSON</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/write-json/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Read-JSON"><a href="#Read-JSON" class="headerlink" title="Read JSON"></a>Read JSON</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/read-json/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Read-Form"><a href="#Read-Form" class="headerlink" title="Read Form"></a>Read Form</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/read-form/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Favicon"><a href="#Favicon" class="headerlink" title="Favicon"></a>Favicon</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/favicon/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="File-Server"><a href="#File-Server" class="headerlink" title="File Server"></a>File Server</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/file-server/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Send-Files"><a href="#Send-Files" class="headerlink" title="Send Files"></a>Send Files</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/send-files/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Stream-Writer"><a href="#Stream-Writer" class="headerlink" title="Stream Writer"></a>Stream Writer</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/stream-writer/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Listen-UNIX-Socket"><a href="#Listen-UNIX-Socket" class="headerlink" title="Listen UNIX Socket"></a>Listen UNIX Socket</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/listen-unix/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Listen-TLS"><a href="#Listen-TLS" class="headerlink" title="Listen TLS"></a>Listen TLS</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/listen-tls/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Listen-Letsencrypt-Automatic-Certifications"><a href="#Listen-Letsencrypt-Automatic-Certifications" class="headerlink" title="Listen Letsencrypt (Automatic Certifications)"></a>Listen
|
||||
Letsencrypt (Automatic Certifications)</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/listen-letsencrypt/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h2 id="Intermediate"><a href="#Intermediate" class="headerlink" title="Intermediate"></a>Intermediate</h2>
|
||||
<h3 id="Send-an-email"><a href="#Send-an-email" class="headerlink" title="Send an email"></a>Send an email</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/e-mail/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Upload-Read-Files"><a href="#Upload-Read-Files" class="headerlink" title="Upload/Read Files"></a>Upload/Read Files</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/upload-files/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Request-Logger"><a href="#Request-Logger" class="headerlink" title="Request Logger"></a>Request Logger</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/request-logger/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Profiling-pprof"><a href="#Profiling-pprof" class="headerlink" title="Profiling (pprof)"></a>Profiling (pprof)</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/pprof/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Basic-Authentication"><a href="#Basic-Authentication" class="headerlink" title="Basic Authentication"></a>Basic Authentication</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/basicauth/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="HTTP-Access-Control"><a href="#HTTP-Access-Control" class="headerlink" title="HTTP Access Control"></a>HTTP Access Control</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/cors/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Cache-Markdown"><a href="#Cache-Markdown" class="headerlink" title="Cache Markdown"></a>Cache Markdown</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/cache-markdown/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Localization-and-Internationalization"><a href="#Localization-and-Internationalization" class="headerlink" title="Localization and Internationalization"></a>Localization
|
||||
and Internationalization</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/i18n/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Recovery"><a href="#Recovery" class="headerlink" title="Recovery"></a>Recovery</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/recover/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Graceful-Shutdown"><a href="#Graceful-Shutdown" class="headerlink" title="Graceful Shutdown"></a>Graceful Shutdown</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/graceful-shutdown/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Custom-TCP-Listener"><a href="#Custom-TCP-Listener" class="headerlink" title="Custom TCP Listener"></a>Custom TCP Listener</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/custom-listener/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Custom-HTTP-Server"><a href="#Custom-HTTP-Server" class="headerlink" title="Custom HTTP Server"></a>Custom HTTP Server</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/custom-httpserver/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Password-Hashing"><a href="#Password-Hashing" class="headerlink" title="Password Hashing"></a>Password Hashing</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/password-hashing/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Flash-Messages"><a href="#Flash-Messages" class="headerlink" title="Flash Messages"></a>Flash Messages</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/intermediate/flash-messages/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h2 id="Advance"><a href="#Advance" class="headerlink" title="Advance"></a>Advance</h2>
|
||||
<h3 id="Transactions"><a href="#Transactions" class="headerlink" title="Transactions"></a>Transactions</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/advanced/transactions/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="HTTP-Testing"><a href="#HTTP-Testing" class="headerlink" title="HTTP Testing"></a>HTTP Testing</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/advanced/httptest/main_test.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Watch-amp-Compile-Typescript-source-files"><a href="#Watch-amp-Compile-Typescript-source-files" class="headerlink" title="Watch & Compile Typescript source files"></a>Watch
|
||||
& Compile Typescript source files</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/advanced/typescript/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Cloud-Editor"><a href="#Cloud-Editor" class="headerlink" title="Cloud Editor"></a>Cloud Editor</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/advanced/cloud-editor/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="Online-Visitors"><a href="#Online-Visitors" class="headerlink" title="Online Visitors"></a>Online Visitors</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/advanced/online-visitors/main.go" class ="line-numbers codepre"></pre>
|
||||
|
||||
<h3 id="URL-Shortener-using-BoltDB"><a href="#URL-Shortener-using-BoltDB" class="headerlink" title="URL Shortener using BoltDB"></a>URL Shortener using BoltDB</h3>
|
||||
<pre data-src="https://raw.githubusercontent.com/kataras/iris/master/_examples/advanced/url-shortener/main.go" class ="line-numbers codepre"></pre>
|
||||
```
|
||||
@@ -1,13 +0,0 @@
|
||||
package examples
|
||||
|
||||
// Category defines the category of which will contain examples.
|
||||
type Category struct {
|
||||
Name string // i.e "Beginner", "Intermediate", "Advanced", first upper.
|
||||
Examples []Example
|
||||
}
|
||||
|
||||
// Example defines the example link.
|
||||
type Example struct {
|
||||
Name string // i.e: Hello World
|
||||
DataSource string // i.e: https://raw.githubusercontent.com/kataras/iris/master/_examples/beginner/hello-world.go
|
||||
}
|
||||
11
internal/cmd/gen/website/recipe/example/example.go
Normal file
11
internal/cmd/gen/website/recipe/example/example.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package example
|
||||
|
||||
// Example defines the example link.
|
||||
type Example struct {
|
||||
Name string // i.e: Hello World
|
||||
DataSource string // i.e: https://raw.githubusercontent.com/iris-contrib/examples/master/hello-world.go
|
||||
Children []Example // if has children the data source is not a source file, it's just a folder, its the template's H2 tag.
|
||||
// needed for the raw templates, we can do a simple func but lets keep it simple, it's a small template file.
|
||||
HasChildren bool
|
||||
HasNotChildren bool
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package examples
|
||||
package example
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/kataras/iris/core/errors"
|
||||
@@ -12,34 +12,21 @@ import (
|
||||
"github.com/russross/blackfriday"
|
||||
)
|
||||
|
||||
// we could directly query and parse the github page for _examples and take
|
||||
// the examples from its folders, without even the need of a readme to be exist. But I will not do that
|
||||
// because github may change its structure to these folders, so its safer to just:
|
||||
// convert the raw readme.md to the html
|
||||
// query the new html and parse its ul and li tags,
|
||||
// markdown syntax for these things will (never) change, so I assume it will work for a lot of years.
|
||||
const (
|
||||
branch = "master"
|
||||
// rootURL = "https://github.com/kataras/iris/tree/" + branch + "/_examples"
|
||||
// rawRootURL = "https://raw.githubusercontent.com/kataras/iris/"+branch"/_examples/"
|
||||
contentsURL = "https://raw.githubusercontent.com/kataras/iris/" + branch + "/_examples/README.md"
|
||||
tableOfContents = "Table of contents"
|
||||
sanitizeMarkdown = true
|
||||
)
|
||||
|
||||
// WriteExamplesTo will write all examples to the "w"
|
||||
func WriteExamplesTo(w io.Writer) (categories []Category, err error) {
|
||||
// if len(categoryName) == 0 {
|
||||
// return nil, errors.New("category is empty")
|
||||
// }
|
||||
// categoryName = strings.ToTitle(categoryName) // i.e Category Name
|
||||
|
||||
// category := Category{
|
||||
// Name: categoryName,
|
||||
// }
|
||||
// Parse will try to parse and return all examples.
|
||||
// The input parameter "branch" is used to build
|
||||
// the raw..iris-contrib/examples/$branch/
|
||||
// but it should be the same with
|
||||
// the kataras/iris/$branch/ for consistency.
|
||||
func Parse(branch string) (examples []Example, err error) {
|
||||
var (
|
||||
contentsURL = "https://raw.githubusercontent.com/iris-contrib/examples/" + branch
|
||||
tableOfContents = "Table of contents"
|
||||
sanitizeMarkdown = true
|
||||
)
|
||||
|
||||
// get the raw markdown
|
||||
res, err := http.Get(contentsURL)
|
||||
readmeURL := contentsURL + "/README.md"
|
||||
res, err := http.Get(readmeURL)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -68,7 +55,8 @@ func WriteExamplesTo(w io.Writer) (categories []Category, err error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// or with just one line (but may break if we add another h2, so I will do it with the hard and un-readable way for now)
|
||||
// or with just one line (but may break if we add another h2,
|
||||
// so I will do it with the hard and un-readable way for now)
|
||||
// readme.Find("h2").First().NextAllFiltered("ul").Children().Text()
|
||||
|
||||
// find the header of Table Of Contents, we will need it to take its
|
||||
@@ -82,14 +70,12 @@ func WriteExamplesTo(w io.Writer) (categories []Category, err error) {
|
||||
return true
|
||||
})
|
||||
|
||||
// println(tableOfContentsHeader.Text())
|
||||
|
||||
if tableOfContentsHeader == nil {
|
||||
return nil, errors.New("table of contents not found using: " + tableOfContents)
|
||||
}
|
||||
|
||||
// get the list of the examples
|
||||
tableOfContentsUL := tableOfContentsHeader.NextAllFiltered("ul")
|
||||
tableOfContentsUL := tableOfContentsHeader.NextFiltered("ul")
|
||||
if tableOfContentsUL == nil {
|
||||
return nil, errors.New("table of contents list not found")
|
||||
}
|
||||
@@ -102,22 +88,42 @@ func WriteExamplesTo(w io.Writer) (categories []Category, err error) {
|
||||
return false // break on first failure
|
||||
}
|
||||
|
||||
categoryName := exampleHrefLink.Text()
|
||||
name := exampleHrefLink.Text()
|
||||
|
||||
println(categoryName)
|
||||
sourcelink, _ := li.Find("a").First().Attr("href")
|
||||
hasChildren := !strings.HasSuffix(sourcelink, ".go")
|
||||
|
||||
category := Category{
|
||||
Name: categoryName,
|
||||
example := Example{
|
||||
Name: name,
|
||||
DataSource: contentsURL + "/" + sourcelink,
|
||||
HasChildren: hasChildren,
|
||||
HasNotChildren: !hasChildren,
|
||||
}
|
||||
|
||||
_ = category
|
||||
// search for sub examples
|
||||
if hasChildren {
|
||||
li.Find("ul").Children().EachWithBreak(func(_ int, liExample *goquery.Selection) bool {
|
||||
name := liExample.Text()
|
||||
liHref := liExample.Find("a").First()
|
||||
sourcelink, ok := liHref.Attr("href")
|
||||
if !ok {
|
||||
err = errors.New(name + "'s source couldn't be found")
|
||||
return false
|
||||
}
|
||||
|
||||
li.Find("ul").Children().Each(func(_ int, liExample *goquery.Selection) {
|
||||
println(liExample.Text())
|
||||
})
|
||||
subExample := Example{
|
||||
Name: name,
|
||||
DataSource: contentsURL + "/" + sourcelink,
|
||||
}
|
||||
|
||||
example.Children = append(example.Children, subExample)
|
||||
return true
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
examples = append(examples, example)
|
||||
return true
|
||||
})
|
||||
|
||||
return nil, err
|
||||
return examples, err
|
||||
}
|
||||
30
internal/cmd/gen/website/recipe/recipe.go
Normal file
30
internal/cmd/gen/website/recipe/recipe.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package recipe
|
||||
|
||||
import (
|
||||
"github.com/kataras/iris/internal/cmd/gen/website/recipe/example"
|
||||
)
|
||||
|
||||
type Recipe struct {
|
||||
Branch string // i.e "master", "v6"...
|
||||
Examples []example.Example
|
||||
}
|
||||
|
||||
// NewRecipe accepts the "branch", i.e: "master", "v6", "v7"...
|
||||
// and returns a new Recipe pointer with its generated and parsed examples.
|
||||
func NewRecipe(branch string) (*Recipe, error) {
|
||||
if branch == "" {
|
||||
branch = "master"
|
||||
}
|
||||
|
||||
examples, err := example.Parse(branch)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
r := &Recipe{
|
||||
Branch: branch,
|
||||
Examples: examples,
|
||||
}
|
||||
|
||||
return r, nil
|
||||
}
|
||||
149
internal/cmd/gen/website/recipe/recipe.html
Normal file
149
internal/cmd/gen/website/recipe/recipe.html
Normal file
@@ -0,0 +1,149 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<title>Iris</title>
|
||||
<meta charset="utf-8">
|
||||
<meta name="description" content="Iris-go - The fastest backend web framework for Go.">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
|
||||
|
||||
<meta property="og:type" content="article">
|
||||
<meta property="og:title" content="Iris">
|
||||
<meta property="og:description" content="Iris-go - The fastest backend web framework for Go.">
|
||||
<meta property="og:image" content="http://iris-go.com/images/icon.svg">
|
||||
|
||||
<meta name="twitter:card" content="summary">
|
||||
<meta name="twitter:title" content="Iris">
|
||||
<meta name="twitter:description" content="Iris-go - The fastest backend web framework for Go.">
|
||||
<meta name="twitter:image" content="http://iris-go.com/images/icon.svg">
|
||||
|
||||
<link rel="icon" href="/images/favicon.ico" type="image/x-icon">
|
||||
|
||||
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600|Roboto Mono' rel='stylesheet' type='text/css'>
|
||||
<link href='//fonts.googleapis.com/css?family=Dosis:500&text=Iris' rel='stylesheet' type='text/css'>
|
||||
<link href='/css/prism.css' rel='stylesheet' type='text/css'>
|
||||
<link href='/css/terminal.css' rel='stylesheet' type='text/css'>
|
||||
|
||||
<!-- main page styles -->
|
||||
<link rel="stylesheet" href="/css/page.css">
|
||||
|
||||
<!-- this needs to be loaded before guide's inline scripts -->
|
||||
<script>
|
||||
window.PAGE_TYPE = "Recipe"
|
||||
</script>
|
||||
|
||||
<!-- ga -->
|
||||
<script>
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
|
||||
(i[r].q = i[r].q || []).push(arguments)
|
||||
}, i[r].l = 1 * new Date(); a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', 'UA-46045347-6', 'iris-go.com');
|
||||
ga('send', 'pageview');
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body class="docs">
|
||||
<div id="mobile-bar">
|
||||
<a class="menu-button"></a>
|
||||
<a class="logo" href="/"></a>
|
||||
</div>
|
||||
<div id="header">
|
||||
<a id="logo" href="/">
|
||||
<img src="/images/logo.png">
|
||||
<span>IRIS</span>
|
||||
</a>
|
||||
<ul id="nav">
|
||||
<li><a href="/{{.Branch}}/start/" class="nav-link">Start</a></li>
|
||||
<li><a href="/{{.Branch}}/recipe/" class="nav-link current">Recipe</a></li>
|
||||
<li><a href="/{{.Branch}}/blogs/" class="nav-link">Blogs</a></li>
|
||||
<li><a target="_blank" href="https://kataras.rocket.chat/channel/iris" class="nav-link">Chat</a></li>
|
||||
<li><a class="donate" style="color:#ff6666;" target="_blank" href="https://github.com/kataras/iris#buy-me-a-cup-of-coffee">Donate</a></li>
|
||||
<!--
|
||||
<li>
|
||||
<form id="search-form">
|
||||
<input type="text" id="search-query-nav"
|
||||
class="search-query st-default-search-input"/>
|
||||
</form>
|
||||
</li>
|
||||
-->
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="main" class="fix-sidebar">
|
||||
|
||||
|
||||
<div class="sidebar">
|
||||
<ul class="main-menu">
|
||||
<li><a href="/{{.Branch}}/start/" class="nav-link">Start</a></li>
|
||||
<li><a href="/{{.Branch}}/recipe/" class="nav-link current">Recipe</a></li>
|
||||
<li><a href="/{{.Branch}}/blogs/" class="nav-link">Blogs</a></li>
|
||||
<li><a target="_blank" href="https://kataras.rocket.chat/channel/iris" class="nav-link">Chat</a></li>
|
||||
<li><a target="_blank" class="donate" style="color:#ff6666;" href="https://github.com/kataras/iris#buy-me-a-cup-of-coffee">Donate</a></li>
|
||||
</ul>
|
||||
<div class="list">
|
||||
<h2>
|
||||
Recipe
|
||||
</h2>
|
||||
<ul class="menu-root">
|
||||
<li>
|
||||
<a href="/{{.Branch}}/recipe/index.html" class="sidebar-link current"></a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="content Recipe with-sidebar ">
|
||||
{{ range $key, $example := .Examples -}}
|
||||
{{ if $example.HasChildren }}
|
||||
<h2 id="{{$example.Name}}">
|
||||
<a href="#{{$example.Name}}" class="headerlink" title="{{$example.Name}}"></a>
|
||||
{{$example.Name}}
|
||||
</h2>
|
||||
{{ range $key, $child := $example.Children -}}
|
||||
<h3 id="{{ $child.Name }}">
|
||||
<a href="#{{ $child.Name }}" class="headerlink" title="{{ $child.Name }}"></a>
|
||||
{{ $child.Name }}
|
||||
</h3>
|
||||
<pre data-src="{{ $child.DataSource }}" data-visible="true" class="line-numbers codepre"></pre>
|
||||
{{- end }} {{- end }}
|
||||
|
||||
{{ if $example.HasNotChildren }}
|
||||
<h2 id="{{ $example.Name }}">
|
||||
<a href="#{{ $example.Name }}" class="headerlink" title="{{ $example.Name }}"></a>
|
||||
{{ $example.Name }}
|
||||
</h2>
|
||||
<pre data-src="{{ $example.DataSource }}" data-visible="true" class="line-numbers codepre"></pre>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
<div class="footer">
|
||||
Contribute to the documentation?
|
||||
<a target="_blank" href="https://github.com/iris-contrib/website/blob/gh-pages/{{.Branch}}/recipe/index.html" >
|
||||
Edit this page on Github!
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<script src="/js/smooth-scroll.min.js"></script>
|
||||
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
<!-- main custom script for sidebars, version selects etc. -->
|
||||
<script src="/js/css.escape.js"></script>
|
||||
<script src="/js/common.js"></script>
|
||||
<script src="/js/prism.js"></script>
|
||||
<!-- fastclick -->
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/fastclick/1.0.6/fastclick.min.js"></script>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
FastClick.attach(document.body)
|
||||
}, false)
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -2,14 +2,49 @@ package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"text/template"
|
||||
|
||||
"github.com/kataras/iris/internal/cmd/gen/website/examples"
|
||||
"github.com/kataras/iris/internal/cmd/gen/website/recipe/example"
|
||||
)
|
||||
|
||||
const tmpl = `
|
||||
{{ range $key, $example := . -}}
|
||||
{{ if $example.HasChildren }}
|
||||
<h2 id="{{$example.Name}}"><a href="#{{$example.Name}}" class="headerlink" title="{{$example.Name}}"></a>{{$example.Name}}</h2>
|
||||
{{ range $key, $child := $example.Children -}}
|
||||
<h3 id="{{ $child.Name }}">
|
||||
<a href="#{{ $child.Name }}" class="headerlink" title="{{ $child.Name }}"></a>
|
||||
{{ $child.Name }}
|
||||
</h3>
|
||||
<pre data-src="{{ $child.DataSource }}"
|
||||
data-visible="true" class ="line-numbers codepre"></pre>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{ if .HasNotChildren }}
|
||||
<h2 id="{{ $example.Name }}">
|
||||
<a href="#{{ $example.Name }}" class="headerlink" title="{{ $example.Name }}"></a>
|
||||
{{ $example.Name }}
|
||||
</h2>
|
||||
<pre data-src="{{ $example.DataSource }}"
|
||||
data-visible="true" class ="line-numbers codepre"></pre>
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
`
|
||||
|
||||
func main() {
|
||||
// just for testing, the cli will be coded when I finish at least with this one command.
|
||||
_, err := examples.WriteExamplesTo(os.Stdout) // doesn't work yet.
|
||||
examples, err := example.Parse("master")
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
text, err := template.New("").Parse(tmpl)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
}
|
||||
|
||||
if err := text.Execute(os.Stdout, examples); err != nil {
|
||||
println("err in template : " + err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user