Read HISTORY.md


Former-commit-id: 82df2d266055818ffafe0ba66b58cf4ed9089922
This commit is contained in:
kataras 2017-06-07 07:20:53 +03:00
parent 1bea8f5803
commit 6282a71a6f
29 changed files with 309 additions and 3362 deletions

View File

@ -2,6 +2,6 @@ I'd love to see more contributions!
Please read [how to create a Proposal](https://github.com/iris-contrib/community-board#creating-a-proposal) first, PR may be rejected if it's not designed as it should.
If you are interested in contributing to the Iris project, please take a time to read and understand the [Code of Conduct](https://github.com/kataras/iris/blob/master/CODE-OF-CONDUCT.md) before submitting your [PR](https://github.com/kataras/iris/pulls), this is how we make Go great.
If you are interested in contributing to the Iris project, please take a time to read and understand the [Code of Conduct](https://github.com/iris-contrib/community-board/blob/master/CODE-OF-CONDUCT.md) before submitting your [PR](https://github.com/kataras/iris/pulls), this is how we make Go great.
Thanks!

View File

@ -24,7 +24,7 @@ This code of conduct applies to all repos and communities for kataras-managed op
## Reporting Code of Conduct Issues
We encourage all communities to resolve issues on their own whenever possible. This builds a broader and deeper understanding and ultimately a healthier interaction. In the event that an issue cannot be resolved locally, please feel free to report your concerns by contacting kataras2006@hotmail.com or kataras@tutanota.com(secure mail).
We encourage all communities to resolve issues on their own whenever possible. This builds a broader and deeper understanding and ultimately a healthier interaction. In the event that an issue cannot be resolved locally, please feel free to report your concerns by mail to kataras2006@hotmail.com or kataras@tutanota.com (secure way).
In your report please include:

18
Gopkg.lock generated
View File

@ -121,12 +121,6 @@
packages = ["."]
revision = "02f928aad224fbccd50d66edd776fc9d1e9f2f2b"
[[projects]]
branch = "master"
name = "github.com/getlantern/systray"
packages = ["."]
revision = "0068f6ae40ea39bfd683043e8452024097fff0e4"
[[projects]]
branch = "master"
name = "github.com/google/go-querystring"
@ -193,12 +187,6 @@
packages = ["."]
revision = "4e24498b31dba4683efb9d35c1c8a91e2eda28c8"
[[projects]]
branch = "master"
name = "github.com/oxtoacart/bpool"
packages = ["."]
revision = "4e1c5567d7c2dd59fa4c7c83d34c2f3528b025d6"
[[projects]]
name = "github.com/pmezard/go-difflib"
packages = ["difflib"]
@ -301,6 +289,12 @@
packages = ["."]
revision = "cd8b52f8269e0feb286dfeef29f8fe4d5b397e0b"
[[projects]]
branch = "master"
name = "github.com/PuerkitoBio/goquery"
packages = ["."]
revision = "2dc93891ab3bcc1dbc2cbf9bc6376c37f6e6f289"
[solve-meta]
analyzer-name = "dep"
analyzer-version = 1

View File

@ -106,10 +106,6 @@
branch = "master"
name = "github.com/gavv/monotime"
[[constraint]]
branch = "master"
name = "github.com/getlantern/systray"
[[constraint]]
name = "github.com/gorilla/websocket"
version = "1.1.0"
@ -177,3 +173,7 @@
[[constraint]]
branch = "v2"
name = "gopkg.in/yaml.v2"
[[constraint]]
branch = "master"
name = "github.com/PuerkitoBio/goquery"

View File

@ -29,6 +29,11 @@ Thanks to [Santosh Anand](https://github.com/santoshanand) the http://iris-go.co
The amount of the next two or three donations you'll send they will be immediately transferred to his own account balance, so be generous please!
# We, 07 June 2017 | v7.0.1
- Proof of concept of an internal release generator, navigate [here](https://github.com/iris-contrib/community-board/issues/2) to read more.
- Remove tray icon "feature", click [here](https://github.com/iris-contrib/community-board/issues/1) to learn why.
# Sa, 03 June 2017
After 2+ months of hard work and collaborations, Iris [version 7](https://github.com/kataras/iris) was published earlier today.
@ -117,8 +122,6 @@ Server
- Able to set custom underline *http.Server(s) with new Host (aka Server Supervisor) feature
- `Done` and `Err` channels to catch shutdown or any errors on custom hosts,
- Schedule custom tasks(with cancelation) when server is running, see [here](https://github.com/kataras/iris/tree/master/_examples/intermediate/graceful-shutdown)
- Taskbar Tray icon (disabled by default)
- Linux users have to download manually some dependencies if `app.WithTrayIcon` is passed on `app.Run`'s as second argument, the logger will print how.
- Interrupt handler task for gracefully shutdown (when `CTRL/CMD+C`) are enabled by-default, you can disable its via configuration: `app.Run(iris.Addr(":8080"), iris.WithoutInterruptHandler)`
Future plans

View File

@ -6,7 +6,7 @@ A fast, cross-platform and efficient web framework with robust set of well-desig
[![Report card](https://img.shields.io/badge/report%20card%20-a%2B-F44336.svg?style=flat-square)](http://goreportcard.com/report/kataras/iris)
[![Support forum](https://img.shields.io/badge/support-page-ec2eb4.svg?style=flat-square)](http://support.iris-go.com)
[![Examples](https://img.shields.io/badge/howto-examples-3362c2.svg?style=flat-square)](https://github.com/kataras/iris/tree/master/_examples#table-of-contents)
[![Godocs](https://img.shields.io/badge/docs-%20reference-5272B4.svg?style=flat-square)](https://godoc.org/github.com/kataras/iris)
[![Godocs](https://img.shields.io/badge/7.0.1-%20documentation-5272B4.svg?style=flat-square)](https://godoc.org/github.com/kataras/iris)
[![Chat](https://img.shields.io/badge/community-%20chat-00BCD4.svg?style=flat-square)](https://kataras.rocket.chat/channel/iris)
[![Buy me a cup of coffee](https://img.shields.io/badge/support-%20open--source-F4A460.svg?logo=data:image%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDAwIDEwMDAiPjxwYXRoIGZpbGw9InJnYigyMjAsMjIwLDIyMCkiIGQ9Ik04ODYuNiwzMDUuM2MtNDUuNywyMDMuMS0xODcsMzEwLjMtNDA5LjYsMzEwLjNoLTc0LjFsLTUxLjUsMzI2LjloLTYybC0zLjIsMjEuMWMtMi4xLDE0LDguNiwyNi40LDIyLjYsMjYuNGgxNTguNWMxOC44LDAsMzQuNy0xMy42LDM3LjctMzIuMmwxLjUtOGwyOS45LTE4OS4zbDEuOS0xMC4zYzIuOS0xOC42LDE4LjktMzIuMiwzNy43LTMyLjJoMjMuNWMxNTMuNSwwLDI3My43LTYyLjQsMzA4LjktMjQyLjdDOTIxLjYsNDA2LjgsOTE2LjcsMzQ4LjYsODg2LjYsMzA1LjN6Ii8%2BPHBhdGggZmlsbD0icmdiKDIyMCwyMjAsMjIwKSIgZD0iTTc5MS45LDgzLjlDNzQ2LjUsMzIuMiw2NjQuNCwxMCw1NTkuNSwxMEgyNTVjLTIxLjQsMC0zOS44LDE1LjUtNDMuMSwzNi44TDg1LDg1MWMtMi41LDE1LjksOS44LDMwLjIsMjUuOCwzMC4ySDI5OWw0Ny4zLTI5OS42bC0xLjUsOS40YzMuMi0yMS4zLDIxLjQtMzYuOCw0Mi45LTM2LjhINDc3YzE3NS41LDAsMzEzLTcxLjIsMzUzLjItMjc3LjVjMS4yLTYuMSwyLjMtMTIuMSwzLjEtMTcuOEM4NDUuMSwxODIuOCw4MzMuMiwxMzAuOCw3OTEuOSw4My45TDc5MS45LDgzLjl6Ii8%2BPC9zdmc%2B)](https://github.com/kataras/iris#buy-me-a-cup-of-coffee)
@ -165,7 +165,7 @@ $ rizla main.go
I'm sorry for taking this personally but I really need to thanks each one of them because they stood up [](https://github.com/kataras/iris#support) for me when others trying to "bullying" my personality in order to deflame Iris.
All of us should read and respect the official [golang](https://golang.org/conduct) and [iris](CODE-OF-CONDUCT.md) community **Code of Conduct**. This type of commitment and communication is the way of making Go great.
All of us should read and respect the official [golang](https://golang.org/conduct) and [iris](https://github.com/iris-contrib/community-board/blob/master/CODE-OF-CONDUCT.md) community **Code of Conduct**. This type of commitment and communication is the way of making Go great.
<!-- on each chance, i.e when iris posts were trending on sites like dzone and medium they spamming an awful full of lies and deflamation blog post. We all should read and respect the official golang's and iris' Code of Conduct. -->
@ -394,7 +394,7 @@ Besides the fact that we have a [community chat][Chat] for questions or reports
Version
------------
Current: v7
Current: v7.0.1
Each new release is pushed to the master. It stays there until the next version. When a next version is released then the previous version goes to its own branch with `gopkg.in` as its import path (and its own vendor folder), in order to keep it working "for-ever".

View File

@ -12,7 +12,7 @@ It doesn't contains "best ways" neither explains all its features. It's just a s
* [Listening](beginner/listening)
* [Common, with address](beginner/listening/listen-addr/main.go)
* [UNIX socket file](beginner/listening/listen-unix/main.go)
* [TLS](beginner/listening/listen-tls)
* [TLS](beginner/listening/listen-tls/main.go)
* [Letsencrypt (Automatic Certifications)](beginner/listening/listen-letsencrypt/main.go)
* [Custom TCP Listener](beginner/listening/custom-listener/main.go)
* [Configuration](beginner/configuration)
@ -70,7 +70,7 @@ It doesn't contains "best ways" neither explains all its features. It's just a s
* [Showcase of the `urlpath` tmpl func](intermediate/view/template_html_3/main.go)
* [Showcase of the `url` tmpl func](intermediate/view/template_html_4/main.go)
* [Inject Data Between Handlers](intermediate/view/context-view-data/main.go)
* [Embedding Templates Into App Executable File](intermediate/view/embedding-templates-into-app)
* [Embedding Templates Into App Executable File](intermediate/view/embedding-templates-into-app/main.go)
* [Sessions](intermediate/sessions)
* [Overview](intermediate/sessions/overview/main.go)
* [Encoding & Decoding the Session ID: Secure Cookie](intermediate/sessions/securecookie/main.go)

View File

@ -12,7 +12,6 @@ func main() {
// Good when you want to modify the whole configuration.
app.Run(iris.Addr(":8080"), iris.WithConfiguration(iris.Configuration{ // default configuration:
DisableBanner: false,
DisableTray: false,
DisableInterruptHandler: false,
DisablePathCorrection: false,
EnablePathEscape: false,

View File

@ -1,4 +1,3 @@
DisableTray: true
DisablePathCorrection = false
EnablePathEscape = false
FireMethodNotAllowed = true

View File

@ -1,4 +1,3 @@
DisableTray: true
DisablePathCorrection: false
EnablePathEscape: false
FireMethodNotAllowed: true

View File

@ -11,9 +11,9 @@ func main() {
// Good when you want to change some of the configuration's field.
// I use that method :)
app.Run(iris.Addr(":8080"), iris.WithoutBanner, iris.WithTray, iris.WithCharset("UTF-8"))
app.Run(iris.Addr(":8080"), iris.WithoutBanner, iris.WithCharset("UTF-8"))
// or before run:
// app.Configure(iris.WithoutBanner, iris.WithTray, iris.WithCharset("UTF-8"))
// app.Configure(iris.WithoutBanner, iris.WithCharset("UTF-8"))
// app.Run(iris.Addr(":8080"))
}

View File

@ -10,5 +10,5 @@ func main() {
app.Handle("GET", "/", func(ctx context.Context) {
ctx.HTML("<b> Hello world! </b>")
})
app.Run(iris.Addr(":8080"), iris.WithTray)
app.Run(iris.Addr(":8080"))
}

View File

@ -31,7 +31,7 @@ func main() {
srv.ListenAndServe() // same as app.Run(iris.Addr(":8080"))
// Notes:
// Banne and Tray are not shown at all. Same for the Interrupt Handler, even if app's configuration allows them.
// Banner is not shown at all. Same for the Interrupt Handler, even if app's configuration allows them.
//
// `.Run` is the only one function that cares about those three.

View File

@ -104,11 +104,6 @@ var WithoutBanner = func(app *Application) {
app.config.DisableBanner = true
}
// WithTray shows the taskbar tray icon.
var WithTray = func(app *Application) {
app.config.EnableTray = true
}
// WithoutInterruptHandler disables the automatic graceful server shutdown
// when control/cmd+C pressed.
var WithoutInterruptHandler = func(app *Application) {
@ -192,14 +187,6 @@ type Configuration struct {
//
// Defaults to false.
DisableBanner bool `yaml:"DisableBanner" toml:"DisableBanner"`
// EnableTray if setted to true then it shows the taskbar tray icon.
// Tray icon is not enabled by-default for linux systems,
// you have to install a dependency first and re-get the Iris pgk:
// $ sudo apt-get install libgtk-3-dev libappindicator3-dev
// "$ go get -u github.com/kataras/xeo
//
// Defaults to false.
EnableTray bool `yaml:"EnableTray" toml:"EnableTray"`
// DisableInterruptHandler if setted to true then it disables the automatic graceful server shutdown
// when control/cmd+C pressed.
// Turn this to true if you're planning to handle this by your own via a custom host.Task.
@ -413,10 +400,6 @@ func WithConfiguration(c Configuration) Configurator {
main.DisableBanner = v
}
if v := c.EnableTray; v {
main.EnableTray = v
}
if v := c.DisableInterruptHandler; v {
main.DisableInterruptHandler = v
}
@ -480,7 +463,6 @@ func WithConfiguration(c Configuration) Configurator {
func DefaultConfiguration() Configuration {
return Configuration{
DisableBanner: false,
EnableTray: false,
DisableInterruptHandler: false,
DisablePathCorrection: false,
EnablePathEscape: false,

View File

@ -1,233 +0,0 @@
Copyright (c) 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Gerasimos Maropoulos nor the name of his
username, kataras, may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Third-Parties:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2014 Brave New Software Project, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,272 +0,0 @@
// +build !linux
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package gui
import (
"sync/atomic"
"github.com/getlantern/systray"
"github.com/kataras/iris/core/errors"
"github.com/kataras/iris/core/gui/icon"
)
var trayRunning int32 // != 0 means a system tray is running
type TrayItem struct {
*systray.MenuItem
title string
checked bool
disabled bool
clickEvents []TrayItemClickEvent
}
type TrayItemClickEvent func(*TrayItem)
func newTrayItem(title string) *TrayItem {
// MenuItem's fields are not exported,
// I could modify the source code to completes my needs
// but I will not because the sys tram is only one
// and its items are not shown until .Show()
// So I will use the AddMenuItem because it adds them with a specific order
// and I want to control the order, so this TrayItem
// will be a wrapper of the *systray.MenuItem and it will be shown as independed when tray host.Show called.
return &TrayItem{title: title}
}
func (i *TrayItem) Check() {
i.checked = true
if i.MenuItem != nil {
i.MenuItem.Check()
}
}
func (i *TrayItem) Uncheck() {
i.checked = false
if i.MenuItem != nil {
i.MenuItem.Uncheck()
}
}
func (i *TrayItem) Checked() bool {
return i.checked
}
func (i *TrayItem) Disable() {
i.disabled = true
if i.MenuItem != nil {
i.MenuItem.Disable()
}
}
func (i *TrayItem) Enable() {
i.disabled = false
if i.MenuItem != nil {
i.MenuItem.Enable()
}
}
func (i *TrayItem) Disabled() bool {
return i.disabled
}
func (i *TrayItem) SetTitle(title string) *TrayItem {
i.title = title
if i.MenuItem != nil {
i.MenuItem.SetTitle(title)
i.MenuItem.SetTooltip(title)
}
return i
}
func (i *TrayItem) SetToolTip(tooltip string) *TrayItem {
return i.SetTitle(tooltip)
}
// always checked by-default
func newTrayItemCheckBox(checkedTitle string, onCheck TrayItemClickEvent,
unCheckedTitle string, onUnCheck TrayItemClickEvent) *TrayItem {
item := newTrayItem(checkedTitle)
item.Check()
item.OnClick(func(i *TrayItem) {
if item.Checked() {
item.SetTitle(unCheckedTitle)
item.Uncheck()
onUnCheck(i)
} else {
item.SetTitle(checkedTitle)
item.Check()
onCheck(i)
}
})
return item
}
const (
sepLine = "────────────────"
)
func newTrayItemSeparator() *TrayItem {
item := newTrayItem(sepLine)
item.Disable()
return item
}
func (i *TrayItem) show() {
activeItem := systray.AddMenuItem(i.title, i.title)
if i.disabled {
activeItem.Disable()
}
if i.checked {
activeItem.Check()
}
i.MenuItem = activeItem
go func() {
for {
<-activeItem.ClickedCh
i.fireClick()
}
}()
}
func (i *TrayItem) OnClick(callback TrayItemClickEvent) *TrayItem {
i.clickEvents = append(i.clickEvents, callback)
return i
}
func (i *TrayItem) fireClick() {
for _, cb := range i.clickEvents {
cb(i)
}
}
type TrayHost struct {
items []*TrayItem // useless
version string
shutdownServerCb func()
startServerCb func()
hideCb func()
}
var Tray = defaultTrayHost()
func defaultTrayHost() *TrayHost {
t := new(TrayHost)
return t
}
func (t *TrayHost) putItem(item *TrayItem) {
t.items = append(t.items, item)
}
func (t *TrayHost) PutItem(title string) *TrayItem {
item := newTrayItem(title)
t.putItem(item)
return item
}
func (t *TrayHost) PutCheckBox(checkedTitle string, onCheck TrayItemClickEvent,
unCheckedTitle string, onUnCheck TrayItemClickEvent) *TrayItem {
item := newTrayItemCheckBox(checkedTitle, onCheck, unCheckedTitle, onUnCheck)
t.putItem(item)
return item
}
func (t *TrayHost) PutSeparator() *TrayItem {
item := newTrayItemSeparator()
t.putItem(item)
return item
}
func (t *TrayHost) SetVersion(v string) *TrayHost {
t.version = v
return t
}
func (t *TrayHost) OnServerStatusChange(start func(), shutdown func()) *TrayHost {
t.startServerCb = start
t.shutdownServerCb = shutdown
return t
}
func (t *TrayHost) OnHide(cb func()) *TrayHost {
t.hideCb = cb
return t
}
func (t *TrayHost) Hide() {
atomic.StoreInt32(&trayRunning, -1)
systray.Quit()
if t.hideCb != nil {
t.hideCb()
}
}
func (t *TrayHost) Show() error {
if running := atomic.LoadInt32(&trayRunning); running != 0 {
return errors.New("A system tray is already running, please close that first")
}
topItems := make([]*TrayItem, 0) // dynamic because we don't know if status btn will be shown
versionBtn := newTrayItem("Version " + t.version)
versionBtn.Disable()
topItems = append(topItems, versionBtn)
// if server status listeners have been registered, then show the online/offline button
// otherwise not.
if t.startServerCb != nil && t.shutdownServerCb != nil {
statusBtn := newTrayItemCheckBox("Online", t.startServerClicked, "Offline", t.shutdownServerClicked)
topItems = append(topItems, statusBtn)
}
topItems = append(topItems, newTrayItemSeparator())
t.items = append(topItems, t.items...)
t.PutItem("Hide").OnClick(t.hideClicked)
systray.Run(t.onTrayReady)
return nil
}
func (t *TrayHost) onTrayReady() {
systray.SetIcon(icon.Data)
systray.SetTitle("Iris web server")
systray.SetTooltip("Iris")
for _, item := range t.items {
item.show()
}
atomic.StoreInt32(&trayRunning, 1)
}
func (t *TrayHost) DisableItem(index int) {
if len(t.items)-1 > index {
t.items[index].Disable()
}
}
func (t *TrayHost) startServerClicked(item *TrayItem) {
if t.startServerCb != nil {
t.startServerCb()
}
}
func (t *TrayHost) shutdownServerClicked(item *TrayItem) {
if t.shutdownServerCb != nil {
t.shutdownServerCb()
}
}
func (t *TrayHost) hideClicked(item *TrayItem) {
t.Hide()
}

View File

@ -1,47 +0,0 @@
// +build !linux
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package host
import (
"context"
"time"
"github.com/kataras/iris/core/gui"
)
// ShowTrayTask is a supervisor's built'n task which shows
// the iris tray icon to the taskbar (cross-platform).
//
// It's responsible for the server's status button.
func ShowTrayTask(version string, shutdownTimeout time.Duration) TaskRunnerFunc {
return func(proc TaskProcess) {
t := gui.Tray
// set the label "Version" to the framework's current Version.
t.SetVersion(version)
// active the status button(online/offline).
t.OnServerStatusChange(
// set the first callback (pressed when unchecked).
func() {
go proc.Host().Serve()
},
// set the second call back (pressed when checked, default status with its label setted to :"Offline".
func() {
// when server is shutting down it will send an "http closed" error ,
// that DeferFlow stops from returning that error and exiting the app
// postpone the execution flow, the interrupt signal will restore the flow
// when ctrl/cmd+C pressed.
proc.Host().DeferFlow()
ctx, cancel := context.WithTimeout(context.TODO(), shutdownTimeout)
defer cancel()
proc.Host().Shutdown(ctx)
})
// render the tray icon and block this scheduled task(goroutine.
t.Show()
}
}

View File

@ -1,28 +0,0 @@
// +build linux
// Copyright 2017 Gerasimos Maropoulos, ΓΜ. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package host
import (
"os"
"time"
)
// ShowTrayTask is a supervisor's built'n task which shows
// the iris tray icon to the taskbar (cross-platform).
//
// It's responsible for the server's status button.
func ShowTrayTask(version string, shutdownTimeout time.Duration) TaskRunnerFunc {
return func(proc TaskProcess) {
os.Stdout.WriteString("Tray icon is not enabled by-default for linux systems,\nyou have to install a dependency first and re-get the Iris pgk:\n")
os.Stdout.WriteString("$ sudo apt-get install libgtk-3-dev libappindicator3-dev\n")
os.Stdout.WriteString("$ go get -u github.com/kataras/iris\n")
// manually:
// os.Stdout.WriteString("remove $GOPATH/src/github.com/kataras/iris/core/host/task_gui_tray_linux.go\n")
// os.Stdout.WriteString("edit $GOPATH/src/github.com/kataras/iris/core/host/task_gui_tray.go and remove the // +build !linux\n")
// os.Stdout.WriteString("edit $GOPATH/src/github.com/kataras/iris/core/gui/tray.go and remove the // +build !linux\n")
}
}

View File

@ -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.

View File

@ -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 &amp; Compile Typescript source files"></a>Watch
&amp; 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>
```

View File

@ -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
}

View 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
}

View File

@ -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"
// 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
)
// 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,
// }
// 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
})
return nil, err
}
examples = append(examples, example)
return true
})
return examples, err
}

View 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
}

View 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>

View File

@ -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())
}
}

12
iris.go
View File

@ -40,7 +40,7 @@ const (
// Version is the current version number of the Iris Web framework.
//
// Look https://github.com/kataras/iris#where-can-i-find-older-versions for older versions.
Version = "7.0.0"
Version = "7.0.1"
)
const (
@ -208,15 +208,11 @@ func (app *Application) NewHost(srv *http.Server) *host.Supervisor {
su.Schedule(host.WriteBannerTask(app.logger, banner+"V"+Version))
}
if !app.config.DisableInterruptHandler {
// give 5 seconds to the server to wait for the (idle) connections.
shutdownTimeout := 5 * time.Second
if app.config.EnableTray {
// start the tray icon to the taskbar (cross-platform) when server started.
su.Schedule(host.ShowTrayTask(Version, shutdownTimeout))
}
if !app.config.DisableInterruptHandler {
// when control/cmd+C pressed.
// when CTRL+C/CMD+C pressed.
su.Schedule(host.ShutdownOnInterruptTask(shutdownTimeout))
}
@ -325,7 +321,7 @@ func Raw(f func() error) Runner {
// then create a new host and run it manually by `go NewHost(*http.Server).Serve/ListenAndServe` etc...
// or use an already created host:
// h := NewHost(*http.Server)
// Run(Raw(h.ListenAndServe), WithoutBanner, WithTray, WithCharset("UTF-8"))
// Run(Raw(h.ListenAndServe), WithoutBanner, WithCharset("UTF-8"))
//
// The Application can go online with any type of server or iris's host with the help of
// the following runners: